- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- FTP Errors
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
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
тАО08-08-2002 12:50 PM
тАО08-08-2002 12:50 PM
One of my customers FTP's a few files weekly to another location. Usually my script works fine but every now and then one of the file transfers does not complete. I can't seem to find a way to get the FTP status code into any useful form. I would like to re-transmit the file if an error occurs. Any ideas out there?
Thanks, Greg
Solved! Go to Solution.
- Tags:
- ftp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-08-2002 12:55 PM
тАО08-08-2002 12:55 PM
Re: FTP Errors
An easier way to do this is with the NET::FTP PERL module. This apparently has all kinds of error checking built in, so if you know PERL that would probably be your best bet.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-08-2002 12:57 PM
тАО08-08-2002 12:57 PM
SolutionI might as well make you bad right off the bat. If you are using some silly scripting other than Perl (specifically the Net::FTP module), you are doing it the hard way. You will need to download and install the module from www.CPAN.org but after that this is really easy. I already have a script that should be very close. Modify the remote host name, login, and passwd and you are ready to rumble.
FILES="file1 file2 file3"
for F in ${FILES}
do
ftp.pl ${F}
STAT=${?}
echo "File: ${F} Result: ${STAT}"
done
you could also simply
ftp.pl ${FILES}
STAT=${?}
to do them all in one shot. 0 means all is well.
2 actually means OK to FTP but that is translated to a zero by the script. You get FTP error checking for free using the Net::FTP
module.
Now throw away your dumb shell scripts and do it the smart way.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-08-2002 01:42 PM
тАО08-08-2002 01:42 PM
Re: FTP Errors
The PERL answer looks great but I am a little confused on how to install a module. Can you tell me the steps involved in loading this Net::FTP module?
Thanks, Greg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-08-2002 01:49 PM
тАО08-08-2002 01:49 PM
Re: FTP Errors
Net::FTP is actually contained in libnet. I suggest that you download and install the library.
Use this link:
http://search.cpan.org/search?dist=libnet
and click on the libnet-1.12.tar.gz link.
This will download the source. You then gunzip it in a tmp directory and then untar the files.
Go to the libnet-1.12 directory directory underneath the directory in which you did the
tar. There will be a README file to guide you through the process. The first thing you will run is perl Makefile.PL. The rest is very, very simple.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-08-2002 04:10 PM
тАО08-08-2002 04:10 PM
Re: FTP Errors
here is how on Perl deprived rookie does it -
ftp -n -v << endl >> /$FTP_LOG
open servername (or ip)
user username userpassword
prompt
mput RC*
quit
endl
grep 'Not connected' $FTP_LOG 1>/dev/null 2>/dev/null
echo $? | read RC
grep 'full' $FTP_LOG 1>/dev/null 2>/dev/null
echo $? | read RC1
grep 'fail' $FTP_LOG 1>/dev/null 2>/dev/null
echo $? | read RC2
grep 'Error writing' $FTP_LOG 1>/dev/null 2>/dev/null
echo $? | read RC3
if [ $RC -lt 1 -o $RC1 -lt 1 -o $RC2 -lt 1 -o $RC3 -lt 1 ]
then
do something (i.e. sleep X amount of tine and resend)
fi
Of course, hard coding the user name and password are not done. A .netrc will preserve the security. Yhis is only an example. Output to /dev/null can be condensed as well.
In any event this is roughly how we handle ftp verification and email upon failures ("then do something".
Best of luck.
Someday I will learn perl as well. Clay has some very good answers to a number of postings that require perl.
dl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2002 08:00 AM
тАО08-09-2002 08:00 AM
Re: FTP Errors
I got the Net::FTP module installed and the PERL script worked great. They use anonymous FTP so all I had to do was to change the hostname and login and everything worked fine. Believe it or not, the very first time I used the script it detected an imcomplete transfer and automatically resent the file!
Dave, thanks for your suggestion but after seeing this PERL script work there is no way I'm going to change. Besides who would want to make A. Clay bad (or mad)?
I have got to learn PERL.
Thanks, Greg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-09-2002 08:07 AM
тАО08-09-2002 08:07 AM
Re: FTP Errors
I'm glad you are now a Perl convert. If you really want to be impressed by Perl, try writing a script that uses sockets. What I used to do in C now works in a scripting language and it just about as fast. I especially like the idea that I can write a sockets based client/server pair and have it work in the Windows world equally well and unchanged.
Regards, Clay