Hello,
I am using the attached Perl script to do FTP between two remote servers by running the script on a windows machine . The source machine for FTP is UNIX and the destination is another windows system.
When I run the code, it gives an error on line 21:
$ftpf->port($port) or die "Error sending port: $!";
use Net::FTP;
# Create connections to both remote servers...
$ftpf = Net::FTP->new('unix system') or die "Can't connect to 'from':
+$!";
$ftpd = Net::FTP->new('windows system') or die "Can't connect to 'dest
+': $!";
# ...and login to them.
$ftpf->login('anonymous') or die "Can't login to 'from'";
$ftpd->login('anonymous') or die "Can't login to 'dest'";
# Place both servers into the correct transfer mode.
# In this case I'm using ASCII.
$ftpf->ascii() && $ftpd->ascii() or die "Can't set ASCII mode: $!";
# Send the PASV command to the destination server.
# This returns a port address.
$port = $ftpd->pasv or die "Can't put FTP host in passive mode: $!";
print $port;
# Send the port address to the source server so it
# knows where to send the data.
$ftpf->port($port) or die "Error sending port: $!";
# Send the RETR and STOU commands to the servers
$rfile = '/pub/swdistrib/conf/os.conf';
$ftpf->retr($rfile) or $ftpf->ok or die "Can't retrieve '$rfile': $!";
+
$sfile = '/swdistrib/os.conf';
$ftpd->stou($sfile) or die "Can't store '$sfile': $!";
# Wait for the transfer to complete
$ftpd->pasv_wait($ftpf) or die "Transfer failed: $!";
$ftpd->close() && $ftpf->close() or die "Can't close connections: $!";
+
$ftpf->quit() && $ftpd->quit() or die "Can't quit ftp connections: $!"
+;
The error says "Error sending port".$! just gives the line num
What could be the possible cause for this error?
Regards
chimni
UPDATE: I run the script as admin on my local machine.
MR.Muskrat your change worked for me.Thanks.
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.