- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- FTP and error codes
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
Discussions
Discussions
Discussions
Forums
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
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
тАО05-11-2007 01:55 AM
тАО05-11-2007 01:55 AM
ftp -i -n
# cat /dir/input
open servername.domain
user name password
bin
ls (just using ls for testing purposes)
close
quit
~
Solved! Go to Solution.
- Tags:
- ftp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2007 02:00 AM
тАО05-11-2007 02:00 AM
Re: FTP and error codes
basically, you need to "log" the output of ftp to a file and then grep for different status codes, like 250. man "ftpd" for status code lists. btw: don't check for the "verbage" as it's not standard across implementations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2007 02:06 AM
тАО05-11-2007 02:06 AM
Re: FTP and error codes
SEND_STATUS=`echo "user $FTP_USER $FTP_PASSWORD
bin
cd $REMOTE_USER
lcd $LOCALDIR
mput $LOCALFILE
bye" | ftp -i -v -n $FTP_HOST | grep -E "^226.*OK.$" |wc -l`
if [ $SEND_STATUS -eq 1 ]
then
echo "File transferred correctly" >> $LOGFILE
exit 0
else
echo "ERROR in ftp\n" >> $LOGFILE
echo "`date`: Error sending $LOCALFILE to user $REMOTE_USER" | mailx -s "ERROR FTP" $MAILTO
exit 1
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2007 02:17 AM
тАО05-11-2007 02:17 AM
Re: FTP and error codes
if you wanted to be paranoid you could do the following steps:
1. checksum the file
2. push transfer the file
3. pull transfer the file back
4. re-calc the checksum
This would highlight any transmission problems, but at the cost of bandwidth and time !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2007 02:29 AM
тАО05-11-2007 02:29 AM
Re: FTP and error codes
For example, to do your example:
ftpget.pl -h servername.domain -u user -p password -B -d /etc -L 'w*'
STAT=${?}
if [[ ${STAT} -ne 0 ]]
then
echo "ftpget failed; status ${STAT}." >&2
fi
Would log you in to a server (and can optionally read .netrc for a password), set binary mode, cd to /etc, and list all files that conform to 'w*'. Error-checking is done at every step and all you have to do is examine the exit status of the process. If it's zero, all was well. You don't even have to know any Perl. Invoke as ftpget.pl -u for full usage.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2007 02:30 AM
тАО05-11-2007 02:30 AM
Re: FTP and error codes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-12-2007 10:58 AM
тАО05-12-2007 10:58 AM
Re: FTP and error codes
Just like ping, there is no meaningful return code about the actual objective because there are so many possibilities and only one number as a return code.
Use the Perl modules.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-12-2007 10:13 PM
тАО05-12-2007 10:13 PM
SolutionUse with the verbose option.
Try the below one:
# cat /dir/input
/usr/bin/ftp -v -n > /var/tmp/ftpscript.log 2> /var/tmp/ftpscript.err <
user name password
prompt
cd /ddir
bin
mput file*
ls /tmp
quit
EOF
#sh /dir/input (run the script input)
after that re-direct /var/tmp/ftpscript.err by mail (or both the output files -log and err) to you.
Rgds.