####Connect to Server open (FD1, ">>$logname") || print FD1 "Couldnt open - write $logname\n" ; my $ftp=new Net::FTP("$server",Timeout=>"300000")|| print FD1 "Can not connect to ftp server\n"; $ftp->login("$username","$passwd")|| print FD1 "Can not login to ftp server\n"; ..... ...... my @files=$ftp->dir or print FD1 "error in dir list--to var-- $dir \n"; .... ..... foreach(@files) { #print "$_\n"; $_=substr($_,41); s/ */ /g; s/^ *//g; chomp; print FD1 "Getting $_\n"; $filename2=$_; $filename=substr($filename2,0,12) ; .... ... if( -f $first_check) { print FD1 "$filename exist, So no need to download \n"; } else { ..... $ftp->binary(); $ftp->get($filename2) or $newerr=1; #|| print "$filename2 can not be downloaded error $!\n"; if ($newerr) { print FD1 "$filename2 can not be downloaded error $!\n"; } else { print FD1 "Got file $filename2 \n"; ...... ..... } } #### TTFILE008498 exist, So no need to download Getting TTFILE008499;1 TTFILE008499 exist, So no need to download Getting TTFILE008500;1 TTFILE008500;1 can not be downloaded error Bad file descriptor Getting TTFILE008501;1 TTFILE008501;1 can not be downloaded error No such file or directory Getting TTFILE008502;1 TTFILE008502;1 can not be downloaded error No such file or directory