Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hanging FTP

Status
Not open for further replies.

pjb

Programmer
May 1, 2001
148
US
I have a shell script that executes an FTP. Occasionally, the FTP hangs (probably on the connect to the other server),and I have to manually kill the job the next morning. Is there anyway to have the FTP time-out and cancel mechanically?
 
Something like this ?
ftp arg list &
sleep 3600 # 1hour time out
kill $!

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
run it inside of a function, execute it inside of a background process in a timed loop.
Code:
function run_ftp
{
#do your ftp stuff here

#end with this in your function
#you dont want to generate a bad return
#if this succeeds
exit 0
}

##MAIN
#run it in the background while the script continues.
run_ftp &

#grab the PID
FTPPID=$!

#set the timer to whatever you want to error on
sleep 300

#kill the ftp process.
kill $FTPPID

#exit on error after timer expires
exit 1
-Hope this helps.




 
i dont know wich OS you are using.
documented is: on solaris, ftp is buggy especially if
running in 'passive' mode and oftener hangs :(((
no longer probls, since i installed 'ncftp' (it's also a
better ftp) on my server.
google for 'SFWncftp.3.0.1.pkg' (or better).


:) guggach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top