srinivasvkumar has asked for the wisdom of the Perl Monks concerning the following question:
Hi Guys, I am not so well versed in perl. I am trying out few things for ftp b/w two servers with out a local copy. For which i am using pasv_xfer. But i am facing the below error Net::FTP: Unexpected EOF on command channel at ftp_files_script.pl line 61 Not able to transfer file Connection reset by peer at ftp_files_script.pl line 61 Here goes my script and output in debut mode
[Script] use FileHandle; use Net::FTP; use Cwd; use Net::FTP::dataconn; open(DAT,$ARGV[3]) or die "not able to open file"; @fil=<DAT>; close(DAT); chomp(@fil); $src_sys=$fil[0]; $tgt_sys=$fil[1]; $file_nm=$fil[2]; $source_dir="$fil[3]"; $target_dir="$fil[4]"; $list_path="$fil[5]"; sub trail_function { $t=shift; print $fil[0]; open(DAT,$file_nm) or die "not able to open file"; @p=grep /$t/, <DAT>; @y=split ((/[|\/]/),"$p[0]"); close(DAT); return; } $src_ftp_conn = new Net::FTP($src_sys,Debug => 1,Passive=>1) or die "$ +src_ftp_conn not able to connect $@\n"; trail_function($ARGV[0]); $src_ftp_conn->login("$y[2]","$y[1]") or die "$src_sys not able to lo +gin $@\n"; print "login to $src_sys successful"; $dat_file="$list_path$ARGV[2]"; $src_ftp_conn->cwd($source_dir) or die "reason is $@"; open(HANDLE,$dat_file) or die "unable to open $dat_file $@"; @list= <HANDLE>; close(HANDLE); $tgt_ftp_conn = Net::FTP->new($tgt_sys,Debug => 1,Passive=>1)or die "$ +tgt_ftp_conn not able to connect $@\n"; trail_function($ARGV[1]); $tgt_ftp_conn->login("$y[2]","$y[1]")or die "$tgt_sys not able to logi +n $@\n"; print "login to $tgt_sys successful"; $tgt_ftp_conn->cwd($target_dir) or die "reason is $@"; $fh = FileHandle::new; foreach $val (@list) { chomp($val); chomp($tgt_ftp_conn); print "The file which we are trying to transfer is $val"; $src_ftp_conn->pasv_xfer($val,$tgt_ftp_conn) or die "Not able t +o transfer file $!"; } $src_ftp_conn->quit; $tgt_ftp_conn->quit;
output in debug Name "main::fh" used only once: possible typo at ftp_files_script.pl line 54. Net::FTP>>> Net::FTP(2.75) Net::FTP>>> Exporter(5.58) Net::FTP>>> Net::Cmd(2.26) Net::FTP>>> IO::Socket::INET(1.29) Net::FTP>>> IO::Socket(1.29) Net::FTP>>> IO::Handle(1.25) Net::FTP=GLOB(0x144e29c0)<<< 220 server1 FTP server (SunOS 5.8) ready. Net::FTP=GLOB(0x144e29c0)>>> user xxx1 Net::FTP=GLOB(0x144e29c0)<<< 331 Password required for xxx Net::FTP=GLOB(0x144e29c0)>>> PASS .... Net::FTP=GLOB(0x144e29c0)<<< 230 User xxx1logged in. Net::FTP=GLOB(0x144e29c0)>>> CWD /path/ Net::FTP=GLOB(0x144e29c0)<<< 250 CWD command successful. Net::FTP=GLOB(0x1476e180)<<< 220 server2 Microsoft FTP Service (Version 5.0). Net::FTP=GLOB(0x1476e180)>>> user xxx2 Net::FTP=GLOB(0x1476e180)<<< 331 Password required for DI. Net::FTP=GLOB(0x1476e180)>>> PASS .... Net::FTP=GLOB(0x1476e180)<<< 230 User xxx2 logged in. Net::FTP=GLOB(0x1476e180)>>> CWD /Path/ Net::FTP=GLOB(0x1476e180)<<< 250 CWD command successful. Net::FTP=GLOB(0x144e29c0)>>> PASV Net::FTP=GLOB(0x144e29c0)<<< 227 Entering Passive Mode (ports) Net::FTP=GLOB(0x1476e180)>>> PORT Net::FTP: Unexpected EOF on command channel at ftp_files_script.pl line 61 Not able to transfer file Connection reset by peer at ftp_files_script.pl line 61.
Please help me in resolving this.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: NET::FTP Connection reset by peer
by cdarke (Prior) on Dec 10, 2009 at 10:00 UTC | |
by srinivasvkumar (Initiate) on Dec 10, 2009 at 13:31 UTC | |
|
Re: NET::FTP Connection reset by peer
by ReturnOfThelonious (Beadle) on Dec 10, 2009 at 09:14 UTC | |
by srinivasvkumar (Initiate) on Dec 10, 2009 at 10:16 UTC |