- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to retry FTP once failed to connect to remote ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2002 07:22 PM
01-20-2002 07:22 PM
I have created a script to ftp to remote site to transfer some files. This script is working fine when remote site is connected but my problems here is that whenever i encounter connection failed due to some error, the script will not retry to ftp to remote site to trnasfer files. Is there a way to solve this problmes.
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2002 07:37 PM
01-20-2002 07:37 PM
Re: How to retry FTP once failed to connect to remote site in unix script
Add the following condition into your script:
If you would like to retry once only, then
==========================================
if echo quit|ftp -nv $FTP_SERVER|grep "Connection refused" >/dev/null 2>/dev/null
then
echo FTP server is not responding
echo Retrying after 10 mins...
sleep 600
else
echo Connected. Initiating FTP transfer...
ftp ...
fi
==========================================
If you would like it to retry again and again until connection, then
==========================================
while ! echo quit|ftp -nv localhost|grep "Connection refused" >/dev/null 2>/dev/null
do
echo Retrying after 10 mins...
sleep 600
done
echo Connected. Initiating FTP transfer...
ftp ...
==========================================
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2002 07:44 PM
01-20-2002 07:44 PM
Re: How to retry FTP once failed to connect to remote site in unix script
2 typos. Please use below. Add the following condition into your script:
A) If you would like to retry once only, then
==========================================
FTP_SERVER=ftp.singnet.com.sg # replace with actual site
if echo quit|ftp -nv $FTP_SERVER|grep "Connection refused" >/dev/null 2>/dev/null
then
echo $FTP_SERVER is not responding
echo Retrying after 10 mins...
sleep 600
echo Connected. Initiating FTP transfer...
ftp $FTP_SERVER ...
else
echo Connected. Initiating FTP transfer...
ftp $FTP_SERVER ...
fi
==========================================
B) If you would like it to retry again and again until connection, then
==========================================
FTP_SERVER=ftp.singnet.com.sg # replace with actual site
while ! echo quit|ftp -nv $FTP_SERVER|grep "Connection refused" >/dev/null 2>/dev/null
do
echo $FTP_SERVER is not responding
echo Retrying after 10 mins...
sleep 600
done
echo Connected. Initiating FTP transfer...
ftp $FTP_SERVER ...
==========================================
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2002 07:54 PM
01-20-2002 07:54 PM
Re: How to retry FTP once failed to connect to remote site in unix script
Can't believe that there are still more typos. :P
Please use below. Add the following condition into your script:
A) If you would like to retry once only, then
==========================================
FTP_SERVER=ftp.singnet.com.sg # replace with actual site
if echo quit|ftp -nv $FTP_SERVER|grep "Connection refused" >/dev/null 2>/dev/null
then
echo $FTP_SERVER is not responding
echo Retrying after 10 mins...
sleep 600
echo 2nd attempt to $FTP_SERVER...
ftp $FTP_SERVER ...
else
echo Connected. Initiating FTP transfer...
ftp $FTP_SERVER ...
fi
==========================================
B) If you would like it to retry again and again until connection, then
==========================================
FTP_SERVER=ftp.singnet.com.sg # replace with actual site
while :;
do
if echo quit|ftp -nv $FTP_SERVER|grep "Connection refused" >/dev/null 2>/dev/null
then
echo $FTP_SERVER is not responding
echo Retrying after 10 mins...
sleep 600
else
echo Connected. Initiating FTP transfer...
ftp $FTP_SERVER ...
exit 0
fi
done
==========================================
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2002 08:42 PM
01-20-2002 08:42 PM
Re: How to retry FTP once failed to connect to remote site in unix script
write something to check for the existence of the file AFTER the get. If it's the right size, ends the right way, looks godd whatever, then don't bother to retry, otherwise, just delete and get again.
Scott.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2002 10:21 PM
01-20-2002 10:21 PM
Re: How to retry FTP once failed to connect to remote site in unix script
Thanks for your reply. I have try your solution but having some problems. Here is the message i get :
ftp: connect : Connection timed out
Connected.Initating FTP transfer
ftp: connect : Connection timed out
#
Below is the script file that i created:
#
LOG=/tmp/test.log
PutFname=/tmp/test
cd /tmp
date > $LOG
while :;
do
if echo quit|ftp -nv 10.11.12.13|grep "Connection refused" >/dev/null 2>/dev/null
then
echo 10.11.12.13 is not responding
echo Retying after 10 mins.....
sleep 600
else
echo Connected.Initiating FTP transfer
ftp -i -v -n << eof >> $LOG
open 10.11.12.13
user userid passwd
put $PutFname
quit
eof
date >> $LOG
exit 0
fi
done
Thank you
Regards,
Frankie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2002 11:48 PM
01-20-2002 11:48 PM
SolutionSince the FTP error messages are not pertaining to "Connection refused" only ie. also includes "Connection timed out" etc., the scripts can be modified as follows:
A) If you would like to retry once only, then
==========================================
FTP_SERVER=ftp.singnet.com.sg # replace with actual site
if echo quit|ftp -nv $FTP_SERVER|grep "Connected to" >/dev/null 2>/dev/null
then
echo Connected. Initiating FTP transfer...
ftp $FTP_SERVER ...
else
echo $FTP_SERVER is not responding
echo Retrying after 10 mins...
sleep 600
echo 2nd attempt to $FTP_SERVER...
ftp $FTP_SERVER ...
fi
==========================================
B) If you would like it to retry again and again until connection, then
==========================================
FTP_SERVER=ftp.singnet.com.sg # replace with actual site
while :;
do
if echo quit|ftp -nv $FTP_SERVER|grep "Connected to" >/dev/null 2>/dev/null
then
echo Connected. Initiating FTP transfer...
ftp $FTP_SERVER ...
exit 0
else
echo $FTP_SERVER is not responding
echo Retrying after 10 mins...
sleep 600
fi
done
==========================================
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2002 07:00 PM
01-21-2002 07:00 PM
Re: How to retry FTP once failed to connect to remote site in unix script
My script is working fine now. Thanks for all the help.
Regards,
Frankie