I hope you guys can help me . My requirement is as below:
Some data files will be ftped by other machine to my machine to the path /home/input As soon as the file is ftped I need to zip it and move the file to /home/zipped path.
I can use the below command to zip zip data.zip data.txt
but how do I find out that file is arrived to /home/input location
The file can arrive any time, so how do I keep watching for it all the day? Is there any command?
Does /home/input directory ingeneral holds any other files ?
if not , you can do a "ls /home/input|wc -l" and can check the count , if count is zero --> it mean no files transfered , if not --> something arrived.
Some FTP-servers are able to run scripts after uploads - check the documentation for your ftp-server.
I would try avoid a script with an endless loop but schedule a script via cron to run every minute.
If available on your system that script can use lsof (or a similar tool) to check for processes that have this file open (= upload in progress).
If the file is quite small, then you probably won't have to worry about a follow up file to flag completion, so using the -f flag for a test should suffice:-
If the file is larger, you need to confirm that the whole file has arrived, consider using the fuser command to look at what has the file open:-
The condition for the while loop ask for the processes accessing the file. The standard error is usually the file name, so this is ditched to /dev/null. We then count the bytes returned, so if there is anything there, a process has the file open. If it is zero, then there are no processes working on the file.
I hope that this helps, but please write back if I have missed the point.
Another thought:-
If fuser fails, because of too many processes in total on the machine (we have this problem) there is an open source tool called lsof that can still run. Command required would be:
... which gives no output at all for a closed file, so you get the answer zero for a closed file or not-zero for an open file.
Robin
Liverpool/Blackburn
UK
Last edited by rbatte1; 12-21-2010 at 09:06 AM..
Reason: Another thought
Shell script logic
Hi
I have 2 input files like with file 1 content as (file1)
"BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt
File 2 contents as fle(2)
"BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt
I want to get... (22 Replies)
Hi,
I need to compare 2 text files with around 60000 rows and 1 column. I need to compare these and write the mismatch data to 3rd file.
File1 - file2 = file3
wc -l file1.txt
58112
wc -l file2.txt
55260
head -5 file1.txt
101214200123
101214700300
101250030067
101214100500... (10 Replies)
Hi Friends,
I'm a great fan of this forum... it has helped me tone my skills in shell scripting. I have a challenge here, which I'm sure you guys would help me in achieving...
File A has a list of job ids and I need to compare this with the File B (*.log) and File C (extend *.log) and copy... (6 Replies)
Hi I am doing a perl script .
I wanted to check if the files have arrived in the target location for current date.
the files format will be some thing like this .
So for 13-sep-2012 the file will be like this.
feedmgr.usfed.t_bills_20120912_20120913173232... (1 Reply)