Programming :: Detect If A File Is Used In Write Mode?
Apr 14, 2011
I have to read files from a linux server. When I copy a file I receivce just a portion of the file I expected if the process generationg ths file is still writing it.
I read the file from a java apllication using SSH/SFTP. How can I detect if the file is still used by the writing process ?
View 4 Replies
ADVERTISEMENT
Oct 4, 2010
Is possible to detect port scanning just by using utilities included in linux (netstat, iptables...), Yes there is utility called psad but I would write some scripts for my own and learn something new
writing own Intrusion Detection System? I am not a C++ geeg, so first thing that comes to my mind is that i will use simple BASH SCRIPT that will interact with iptables and monitor user activity, network activity etc. (but I thing that would not be good solution due to performance and capabilities, and also I am not familliar with memory in linux at all). I was reading aboud SNORT HIDS, NIDS... AFAIK some information can be obtainet from /proc but I have no idea which values should be monitored.
View 1 Replies
View Related
Mar 11, 2009
write a C program to detect whether the Ethernet cable is plugged or unplugged. I found out by using a command "nm-tool" in Linux terminal will show me whether a Ethernet cable is plugged or not. If Ethernet cable is plugged, in the device part of eth0, the Hardware Link of Wired Settings will indicate a "yes" and "no" if no Ethernet cable. Hence, in my previous code, I use one function called popen to read the state as shown below:
PHP Code:
[code]....
However, now my project wish to not use the NetworkManager (where the "nm-tool" command comes from). And this gives me trouble to detect the Ethernet cable. So is there any other method for me to detect the Ethernet cable in C programming?
View 8 Replies
View Related
Apr 1, 2011
I want to write a script that will detect all the unwanted files in a particular directory and delete them in one fly..
View 11 Replies
View Related
Jul 17, 2009
Because I forgot to bring a portable hard drive, I cannot boot to a linux OS.
The reason is that the /etc/fstab has a line that is
Quote:
And ext3-datadisk is on the portable hard drive.
The booting process stopped when it prompts for a root passwd or Ctl-D to reboot.
I keyed in the root passwd, and a (File Recovery) prompt appeared.
I tried to vi /etc/fstab but I cannot save the edited /etc/fstab.
How can I boot successfully in this case ?
View 3 Replies
View Related
Jul 19, 2011
how to detect if a file is being opened by any application so that i can block it just before opening it... Actually i am working on android and using iNotify in JNI to detect the OPENING of a file...but the file is getting opened before the iNotify detects it..and therefore its displaying the contents of the file unmodified .. The actual requirement is that if anyone is trying to open the file it should be modified by my program and then the modified file should be opened.
View 10 Replies
View Related
Dec 6, 2010
I'd like to ask about archive mounter feature, can I mount zip file with read write mode? can gvfsd-archive do that?, or I must use fuse-zip to mount it? If I must use fuse-zip, how I wrap it so I can use it via nautilus or via gvfs-fuse-daemon
View 4 Replies
View Related
Jun 26, 2011
I have the following problem. I call a C++ program from a Java servlet by using Runtime exec. The OS is ubuntu and I use Netbeans 7.0 with Glassfish 3.1 web server.The program executes but it does not open and write into a specified file in a specified folder. The same C++ program compiled under Windows opens and writes this file.How can I solve this problem in Linux?
View 2 Replies
View Related
Apr 5, 2011
I'm running a simple backup and log script that is cronjobed to run twice a day. So currently, when new data is added to the log, its added to the direct bottom of the log file. However, I would like to have it printed to the very top of the log. The code is attached, I can't quote it in here because I am a new user and the system thinks I have url's in it, when they are just paths.
View 2 Replies
View Related
Jan 15, 2010
I am having trouble getting some code to work. It takes an input file (csv) and converts it to an XLS. The problem is that I can't seem to get a header to be printed first...
Code:
use Spreadsheet::WriteExcel;
my $input = $ARGV[0];
[code]...
View 5 Replies
View Related
Dec 12, 2008
I am a beginner with php ,trying to work my way through.
I have a file to be written with particular indentation and by appending some special characters...
this is the o/p file i wanted. could anyone please guide me as to how i can write it? code...
View 1 Replies
View Related
Oct 13, 2010
I first found something called lds(linker script) file.
And now I am willing to do a test with __attribute__((section)) to make a function stay in a private section. Sounds fun to me.
Part of my source code looks like this
By objdump, I didn't find a section called "my_own".
View 2 Replies
View Related
Oct 12, 2010
I'm writing output of top command to a file However since top does not provide time I would like to append the 'date' command and then write all this to a file.
so something like top -d 1 -b; echo 'date' >>file
View 1 Replies
View Related
May 24, 2011
i am working on this thread: [URL] if it is better to open a file every time i need to write to it or should i keep a file open the whole time and when i am done with the script, close it and sendmail it out?
Or i just thought of this: i could keep concatenating to a string and just sendmail when done.
View 2 Replies
View Related
Oct 4, 2010
Its my first post in here so please be patient I am trying to use regex in perl script to detect allowed words from the file and then print output to the screen.
As an example : I have text file with orders and returns :
Item2-SKU-2-11.08.2010-online
Item3-SKU-3-11.09.2010-return
Item4-SKU-4-11.09.2010-store
My question: is it possible to make sure that i am ony outputing to the screen orders based on few conditions like Item,order form e.g. online.And is it possible to have multiple matches (Item2 only diplay if ordered online etc)
View 1 Replies
View Related
Feb 15, 2011
At the moment I got my md5sum checking working which I write to a text file and see below.
If the md5sum works it will write the output to check2.md5 test.txt: OK
If the md5sum fails it will write test.txt: FAILED
How do I write if statement to check the output whether or not the md5sum failed or not ?
check1="/home/ops/Desktop/test1/check1.md5"
check2="/home/ops/Desktop/test1/check2.md5"
cd /home/ops/Desktop/test1
md5sum test.txt > $check1
[Code]....
View 2 Replies
View Related
Mar 1, 2011
Write some simple script?
Heres what Im trying to do:
-Qjackctl has a config file which is modified each time QjackCtl is shut down. This means that whatever preset is in use when QjackCtl closes is written into the QjackCtl config file as the DEFAULT PRESET, for the next time QjackCtl starts (or at least this is how I understand it).
-I want to edit a specific line in the QjackCtl.config file, which specifies the DEFAULT PRESET. Obviously its easy to do manually, but I want to do it using a shell script which runs automatically on StartUp so that QjackCtl starts every time with the same DEFAULT PRESET, NOT the last one used.
-Unfortunately Im not at my Linux system right now (which is KXStudio/Kubuntu), but I believe the QjackCtl.config line looks something like this: DEF_PRESET=alsa (where alsa is the name of the preset)
PRESET1=alsa
PRESET2=firewire
I want a shell script which changes the line DEF_PRESET=alsa to DEF_PRESET=alsa, even when it may currently exist as DEF_PRESET=firewire due to occasions when firewire was the active preset when Qjackctl was last closed. I notice that the application in KDE that enables the user to set which applications open automatically on StartUp also allows the user to select shell scripts.
Ive done some research, as a beginner, and Im led to believe I might need to use AWK and/or CHMOD. I could have a go at writing a shell script but Im always wary about experimenting with StartUp scripts/operations because obviously if I get it wrong and make my system unusable, then because its going to run first thing on each boot, Id have great difficulty disabling it.
View 3 Replies
View Related
Jan 20, 2011
I have a bash script that checks for contents in a folder every 15 seconds and then acts on it's contents. This works great for the average size file however on very large files it starts acting on the file before it's completely written. Is there a facility in bash shell to get a file complete signal or such? here is trigger to launch a larger script.
Code:
#!/bin/sh
while true
do
$HOME/bin/hpgl.sh >/dev/null 2>&1 &
[code].....
View 10 Replies
View Related
Apr 2, 2010
I am a novice to the shell script. In my system from db server the log files are enerating with the name log1.txt,log2.txt..... It is capable of keeping 10 files at a time in dir called /db/sis/log1.txt. I want to copy the log1.txt to another directory when ever it generating by attaching the time stamp to it for the back-up purpose. this files will be there for a period of 24 hours. after that the back-up dir should be cleared and it start copying again the fresh file from the same dir.
View 3 Replies
View Related
Oct 30, 2010
How can I write to a file multiple times using fwrite without affecting the previous writes?The method shown below accepts a file name, buffer and offset. The method opens the file in reading/writing mode and writes the content of the buffer at offset.
View 1 Replies
View Related
Jul 3, 2009
I am trying to find / write a shell script that will go through a file organized like this (but with thousands of lines)...
93,5.00,"contig00002",169,83,"jgi|Brafl1|100379|fgenesh2_pg.scaffold_359000019"
579,1.00,"contig00003",3,380,"jgi|Brafl1|114745|estExt_fgenesh2_pm.C_1200006"
450,5.00,"contig00007",2,352,"jgi|Brafl1|274326|estExt_GenewiseH_1.C_8420008"
...and check the region of each line between the second and third pipes (the 6-digit numbers) against the values in the first column of a separate text file in CSV format like this...
274326,"Wnt family of developmental regulators"
114745,"FOG: Hormone receptors"
100379,"Transcription factor tinman/NKX2-3, contains HOX domain"
...and when they match, replace the value to the right of the third pipe (e.g., fgenesh2_pg.sca...) with the value in the second column in the CSV file associated with that number.
View 4 Replies
View Related
Apr 7, 2010
i am trying to write a program which will read input from a text file, check if each line contains any alphabets and then display a message imforming me if there is an alphabet in each line. My text file is formatted in this way...
[Code]....
View 2 Replies
View Related
Jan 31, 2011
I have a folder of 2 many files that the old ls just hangs.
I am trying to write some log files such as;
I don't mind doing one at a time, but I am just playing and even getting the listing I am not getting the date stamp, I have the following;
That does create the file, but all the files look like this;
So basically it's just sticking that ls inside the log file and not actually running the ls, so how can I use the above type to get files just created per year?
View 2 Replies
View Related
Mar 10, 2010
like my alias a retired person, and Its never to late to learn something½ve just installed Ubuntu and found a tutorial online about bash-script.Manage some, but I cant to this one:[Write a script that makes file executable and writes a message that it has been done.If I run the command > <scriptName> <fileName> , then the file fileName should be executable and then it should indicate that fileName have been executable.]
Ive read man pages up-n-down and search the web, and I think I should let the script use chmod and ls -l, but I cant get the hole picture here. Actually I have nothing to show up, so I hope someone could help me with some ideas or a soloution - just to the how it should look.This is my first post, ever, at a forum like this, so please be nice if I didnt follow any rules here, I dont know if you even will answer this post, but at least give me some clues, a skeleton-code ti be based on
View 2 Replies
View Related
Jul 16, 2010
Something very handy to do in a Linux shell, is manipulating files and strings - essentially parsing data. Write a utility which will scan in a text file and search and replace strings. We also want to keep track of how many strings we've replaced.
I know that my command would look like this: <utility name> <filename> <stringToSearchFor> <stringToReplaceWith>
Code: #!/bin/bash
[code]....
View 2 Replies
View Related
Aug 5, 2010
trying read serial COM port and want to write that received data to file, now its writing only one sentence, but i want to write full file which coming on serial port, as i'm sending file from hyper terminal and reading on linux pc, If i put while loop its not writing anything,without while loop its writing only one line and if send big file then application terminates and then writes to file.But i need do write any size which coming on serial port.Finally i want write full file which is coming on hyper terminal, after writing the file it has wait for next data. This is my code,
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
[code]...
View 9 Replies
View Related
Nov 17, 2008
I need to write a batch file for windows that automatically starts the cygwin tool in windows and executes the unix scripts.Previously we had these scripts in unix server.Now we need to migrate them to Windows server.For this reason we are using cygwin tool that allows the scripts to be executed on Windows server.We had written a batch file that starts the cygwin tool,but we were not able to execute the unix scripts.How can we write a batch file such that it executes all the unix scripts in cygwin.
View 5 Replies
View Related
Oct 4, 2010
Is possible to detect port scanning just by using utilities included in linux (netstat, iptables...), Yes there is utility called psad but I would write some scripts for my own and learn something new
I am not a C++ geeg, so first thing that comes to my mind is that i will use simple BASH SCRIPT that will interact with iptables and monitor user activity, network activity etc. (but I thing that would not be good solution due to performance and capabilities, and also I am not familliar with memory in linux at all). I was reading aboud SNORT HIDS, NIDS... AFAIK some information can be obtainet from /proc but I have no idea which values should be monitored.
View 1 Replies
View Related
Oct 31, 2010
How I do detect the usb device when I'm on cli mode? This is possible or not?
View 2 Replies
View Related
Nov 17, 2009
Ive installed Gaussian '03 on fedora Core 10, but I'm unable to run it. It aborts and i get the following error
Code:
Erroneous write during file extend. write -1 instead of 4096
Probably out of disk space.
Write error in NtrExt1
View 3 Replies
View Related