HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: FTP Results
Operating System - HP-UX
1834604
Members
4409
Online
110069
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
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
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
04-09-2003 10:33 AM
04-09-2003 10:33 AM
FTP Results
Hello Everybody!
In a shell script...
How i can to know when a FTP was sucessful??
Where i can save the result of a sucessful or failed FTP?
Thanks a lot!
Freshman
In a shell script...
How i can to know when a FTP was sucessful??
Where i can save the result of a sucessful or failed FTP?
Thanks a lot!
Freshman
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2003 10:46 AM
04-09-2003 10:46 AM
Re: FTP Results
In the past, I used to do this stuff in the shell but now I NEVER do because I have found a much cleaner way to do it that makes error trapping duck soup. Do this stuff in Perl using the Net::FTP module which is available from http://www.cpan.org .
Here's how simple it can be:
#!/usr/bin/perl -w
use Net::FTP;
use strict;
my $ftp = Net::FTP->new("remotehost",Debug => 0);
$ftp->login("cstephen","top_secret");
$ftp->cwd("/tmp");
$ftp->get("myfile");
my $stat = $ftp->status;
my $full_stat = $ftp->code;
# $stat contains the first digit; usually all
# that you need to do is test if it is equal
# to 2. $full_stat contains the full 3-digit
# value but is seldom needed
printf("Status: %d Full Status: %d\n",$stat,$full_stat);
# Sample Test
if ($stat == 2)
{
print "Get was good\n";
}
else
{
print "Get was bad\n";
}
$ftp->quit;
I think if you start using this module you will never go back to shell scripting FTP. Moreover, these same scripts will run in the NT world. You can download a free version of perl for windows at http://www.activeperl.com.
Note that the answer is now the same on UNIX and NT and on the same subnet or across the net. Error checking in traditional scripts is far from easy; it can be done but why bother?
Perl makes it so simple.
Notice that this method easily handles the error checking. If you like, you can use the shell for most of your script and simply use a bit a perl for the actual FTP transfers. In that case add the statement exit($stat) to the perl script and then your shell script does have a valid status indication.
Here's how simple it can be:
#!/usr/bin/perl -w
use Net::FTP;
use strict;
my $ftp = Net::FTP->new("remotehost",Debug => 0);
$ftp->login("cstephen","top_secret");
$ftp->cwd("/tmp");
$ftp->get("myfile");
my $stat = $ftp->status;
my $full_stat = $ftp->code;
# $stat contains the first digit; usually all
# that you need to do is test if it is equal
# to 2. $full_stat contains the full 3-digit
# value but is seldom needed
printf("Status: %d Full Status: %d\n",$stat,$full_stat);
# Sample Test
if ($stat == 2)
{
print "Get was good\n";
}
else
{
print "Get was bad\n";
}
$ftp->quit;
I think if you start using this module you will never go back to shell scripting FTP. Moreover, these same scripts will run in the NT world. You can download a free version of perl for windows at http://www.activeperl.com.
Note that the answer is now the same on UNIX and NT and on the same subnet or across the net. Error checking in traditional scripts is far from easy; it can be done but why bother?
Perl makes it so simple.
Notice that this method easily handles the error checking. If you like, you can use the shell for most of your script and simply use a bit a perl for the actual FTP transfers. In that case add the statement exit($stat) to the perl script and then your shell script does have a valid status indication.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2003 10:48 AM
04-09-2003 10:48 AM
Re: FTP Results
Juan:
Write the output of the dir command to a ftp log file.
dir filename >> ftp.log
within your ftp script.
DR
Write the output of the dir command to a ftp log file.
dir filename >> ftp.log
within your ftp script.
DR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2003 03:57 PM
04-10-2003 03:57 PM
Re: FTP Results
Juan -
This is a standard we use extensively. Please note that if you with to protect ftp passwords then investigate .netrc.
date > $LOGDIR/ftp.log
ftp -n -v <<-endl>> $LOGDIR/ftp.log
open ftpservername
user USER PASSWD
ascii
put $FTP_FILE
quit
endl
Welcome to the forums.
Best regards,
dl
This is a standard we use extensively. Please note that if you with to protect ftp passwords then investigate .netrc.
date > $LOGDIR/ftp.log
ftp -n -v <<-endl>> $LOGDIR/ftp.log
open ftpservername
user USER PASSWD
ascii
put $FTP_FILE
quit
endl
Welcome to the forums.
Best regards,
dl
"I'm not dumb. I just have a command of thoroughly useless information."
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
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP