I'm trying to create a simple perl script to FTP a file through a gateway using Net::FTP.
I can do this from the UNIX command line by:
- ftping the gateway "ftp ftpgateway.mycompany.com"
- logging in to the gateway "ftpgateway_username ftpgateway_password"
- then entering the command "quote site www.destination.com"
- then logging into the destination machine "user destination_username destination_password"
- turning off passive mode "passive"
- then transferring the file "put file"
How can I do this in Perl? I've got the following:
my $ftp;
if ($ftp = Net::FTP->new("ftpgateway.mycompany.com",
Debug => '1',
Passive => '0')) {
print "Connected.\n";
} else {
print "Couldn't connect.\n";
exit;
}
if ($ftp->login("ftpgateway_username", "ftpgateway_password")) {
print "Login sucessful\n";
} else {
print "Login failed.\n";
exit;
}
if ($ftp->site("www.destination.com")) {
print "opened www.destination.com.\n";
} else {
print "Couldn't open destination.com.\n";
exit;
}
if ($ftp->quot("user destination_username destination_password")) {
print "Logged into desination.com.\n";
} else {
print "Couldn't log into destination.com.\n";
exit;
}
if ($ftp->put("file1.txt")) {
print "Put file1.txt\n";
} else {
print "Couldn't put file1.txt.\n";
exit;
}
I get logged in ok, but when I try to the put command I get the error :
Net:FTP=GLOB(0x819dd68)<<< ftp: setsockopt (reuse addresss) Invalid ar
+gument
What's going wrong?
Andrew
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.