- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Automatically detecting success or failure of ftp ...
Operating System - HP-UX
1822158
Members
3409
Online
109640
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО05-11-2001 03:39 AM
тАО05-11-2001 03:39 AM
Hi,
I have an ftp process running from a shell script. It is something like this:
{
for host in nemail
do
echo "
open $host
user joe joepass
lcd /archive/dbeirne/admin/testdir1/
ascii
mput p*
close
"
done
} | ftp -i -n
I want to be alerted if the ftp fails for any reason, ie. cannot connected to the host, the username or password is incorrect, etc. I have tried using the standard $? variable, but this shows success even if the ftp fails. Is there a simple way of checking for failures of this type of script, and running a command like sending a page or whatever.
I know that I can grep through it's logfile for errors, but this is cumbersome as it's logfile is being appended to and is quite large, and contains some historic errors.
Thanks in advance.
Dermot.
I have an ftp process running from a shell script. It is something like this:
{
for host in nemail
do
echo "
open $host
user joe joepass
lcd /archive/dbeirne/admin/testdir1/
ascii
mput p*
close
"
done
} | ftp -i -n
I want to be alerted if the ftp fails for any reason, ie. cannot connected to the host, the username or password is incorrect, etc. I have tried using the standard $? variable, but this shows success even if the ftp fails. Is there a simple way of checking for failures of this type of script, and running a command like sending a page or whatever.
I know that I can grep through it's logfile for errors, but this is cumbersome as it's logfile is being appended to and is quite large, and contains some historic errors.
Thanks in advance.
Dermot.
Happy is harder than money. Anyone who thinks money will make them happy, doesn't have money.
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2001 03:57 AM
тАО05-11-2001 03:57 AM
Re: Automatically detecting success or failure of ftp script
Hi Dermot:
I think you're stuck parsing the log of each session. Use the numbers associated with the text of the messages to discern the success or failure of the process. Look at the man pages (1M) for 'ftpd': "Every command produces at least one reply, although there may be more than one. A reply consists of a three-digit number, a space, some text...The number must conform to this standard, but the text can vary...The first digit of the message indicates whether the reply is good, bad, or incomplete."
Set the '-v' [verbose] option with each ftp and redirect stdout & stderr to a file. Parse the messages from the session and look at the at the first digit of the messages. This is the most rigorous approach, I think, to ascertaining the success or failure of a session.
...JRF...
I think you're stuck parsing the log of each session. Use the numbers associated with the text of the messages to discern the success or failure of the process. Look at the man pages (1M) for 'ftpd': "Every command produces at least one reply, although there may be more than one. A reply consists of a three-digit number, a space, some text...The number must conform to this standard, but the text can vary...The first digit of the message indicates whether the reply is good, bad, or incomplete."
Set the '-v' [verbose] option with each ftp and redirect stdout & stderr to a file. Parse the messages from the session and look at the at the first digit of the messages. This is the most rigorous approach, I think, to ascertaining the success or failure of a session.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2001 05:15 AM
тАО05-11-2001 05:15 AM
Re: Automatically detecting success or failure of ftp script
Insert in shell script if>then>else with exit 0 and exit 1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2001 06:17 AM
тАО05-11-2001 06:17 AM
Solution
Dermot,
We use something like this:
# Initiate FTP session and transfer files
{
ftp -vin < open hostname
user blah passwd 0
del filename
bin
put $dir/filename filename
EOF
} | grep -e "226 Closing" -e "226 Transfer complete." -e "226 ASCII Transfer com plete."> /dev/null
# Report errors via email
if [ $? -ne 0 ]
then
mailx -s "ftpbatch.sh ftp error to hostname" $MAILLIST > /dev/null
fi
It seems to do the job, but we still have some problems with it. I've actually swapped out this process because it was failing so many times to use ncftp. We have to transfer some files to an offsite NT server and it was hanging way too much, so I opted to use ncftp for it's advanced configuration capabilites:
http://hpux.connect.org.uk/hppd/hpux/Networking/FTP/ncftp-3.0.2/
Hope that helps.
- Mike
We use something like this:
# Initiate FTP session and transfer files
{
ftp -vin <
user blah passwd 0
del filename
bin
put $dir/filename filename
EOF
} | grep -e "226 Closing" -e "226 Transfer complete." -e "226 ASCII Transfer com plete."> /dev/null
# Report errors via email
if [ $? -ne 0 ]
then
mailx -s "ftpbatch.sh ftp error to hostname" $MAILLIST > /dev/null
fi
It seems to do the job, but we still have some problems with it. I've actually swapped out this process because it was failing so many times to use ncftp. We have to transfer some files to an offsite NT server and it was hanging way too much, so I opted to use ncftp for it's advanced configuration capabilites:
http://hpux.connect.org.uk/hppd/hpux/Networking/FTP/ncftp-3.0.2/
Hope that helps.
- Mike
The network is the computer, yeah I stole it from Sun, so what?
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP