[Script] use FileHandle; use Net::FTP; use Cwd; use Net::FTP::dataconn; open(DAT,$ARGV[3]) or die "not able to open file"; @fil=; 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/, ; @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 login $@\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= ; 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 login $@\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 to transfer file $!"; } $src_ftp_conn->quit; $tgt_ftp_conn->quit;