- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Automatically FTP logon and Grab file
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
08-30-2006 08:22 AM
08-30-2006 08:22 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2006 08:27 AM
08-30-2006 08:27 AM
SolutionAs an example:
typeset -i STAT=0
ftpget.pl -h remotehost -l mickey -p topsecret -A -d /xxx/yyy myfile
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
echo "Ok"
else
echo "Failed; status = ${STAT}" >&2
fi
exit ${STAT}
This script will also use a .netrc file so that it is not necessary to pass the password on the command line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2006 08:28 AM
08-30-2006 08:28 AM
Re: Automatically FTP logon and Grab file
#!/usr/bin/perl
use Net::FTP;
$ftp = Net::FTP->new("servername", Debug => 0);
$ftp->login("username",'password');
$ftp->cwd("/tmp");
$ftp->get("myfile.txt");
$ftp->quit;
replace servername, etc. with appropriate values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2006 08:32 AM
08-30-2006 08:32 AM
Re: Automatically FTP logon and Grab file
If the exit status is 0; all of those steps worked. That's the beauty of using Perl's Net::FTP module; the error-checking is free. It's rather messy to properly capture all the errors from FTP in a shell script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2006 08:33 AM
08-30-2006 08:33 AM
Re: Automatically FTP logon and Grab file
There a several variations and this is one:
{ echo "open $myhost
user $user $password
get $remotefile $localfile
close"
} | ftp -i -n -v
For a bit better security look at the manpages for 'netrc(4)' and use the '.netrc' autologin approach.
Regards!
...JRF...