The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > Linux
Google UNIX.COM


Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Download HP-UX prashantbhushan HP-UX 1 03-06-2008 03:51 AM
How to direct a script to a new web page after a script got completed? rajbal Shell Programming and Scripting 2 05-22-2007 09:32 AM
download kabouter5454 UNIX for Dummies Questions & Answers 1 12-20-2005 02:39 PM
killing a unix job after the job process gets completed dtazv SUN Solaris 7 09-28-2005 04:18 AM
Retrieving the execution time of a completed command marina UNIX for Dummies Questions & Answers 2 09-06-2005 01:21 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 06-15-2005
Registered User
 

Join Date: Jun 2005
Posts: 3
When a FTP download is completed

I receive files by FTP in an input directory. Every 10 seconds a process checks if some new file has arrived to the input directory and then the process moves them to another directory to be read by a second process.

The problem is that there is no way to know if the download has finished or not. Sometimes my process moves the file when I have received only a part of it.
Is there any way to know if the FTP download is completed ? I have tested the file with 'lsof', 'stat', ... but it doesn't work.

The same process works fine in AIX. If I try to open a file that is downloading at the same time, I receive an error 'Resource is busy'. I use this error to check if the download is completed. But in Linux ( SuSe ) I don't receive any error.

Thanks
Reply With Quote
Forum Sponsor
  #2  
Old 06-15-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,003
while I believe there's no "bullet-proof" solution to this.... you can try using 'fuser' [or lsof if you have one] to see if a file is being used by someone else.

Worth looking into at least.....
Reply With Quote
  #3  
Old 06-15-2005
Just Ice's Avatar
Lights on, brain off.
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 629
try checking for the ftp connection ...

Code:
#! /bin/ksh

ftpOn=$(netstat -a | awk '/ESTABLISHED/ && /ftp/ {print $2}')

if [ ! $ftpOn ]
then
    echo "ok to proceed"
fi

exit 0

Last edited by Just Ice; 06-15-2005 at 09:20 AM.
Reply With Quote
  #4  
Old 06-15-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,003
there might be multiple unrelated ftp sessions
Reply With Quote
  #5  
Old 06-15-2005
Just Ice's Avatar
Lights on, brain off.
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 629
true ... it might be better to combine the netstat-ftp check with fuser so there is some sort of confirmation that the file is indeed being written to ...
Reply With Quote
  #6  
Old 06-15-2005
Registered User
 

Join Date: Oct 2002
Posts: 676
Also, it might be possible to ask the ftp transmitter to send another file when the first ftp is complete. It would be a 0 byte or small file and then you would just check for the existense of that file.
Reply With Quote
  #7  
Old 06-15-2005
Just Ice's Avatar
Lights on, brain off.
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 629
that might sound like the easiest option but that would mean 2 scripts have to be modified ... considering that the same script works well in another platform --- i would opt to just modify 1 script myself as that would keep the appearance of new "features" to a minimum ...
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0