Morning I am trying to unlink files when I receive a ftp return code of 0 or successful but I keep getting an error message of 'can't take log of 0' and gives me the line at
"if ( $ftpsub_rc == 0 ) { unlink( $file),
===============
#!/usr/bin/perl
# The files are moved in batch mode.
my $now=localtime;
open(LOG, ">>/usr/local/cyclone/logs");
$edioldtmp_dir = "/local/ediold/tmp";
opendir(DIR, $edioldtmp_dir);
print "Open dir\n";
opendir(EDIOLDTMP, $edioldtmp_dir) or die "Can't open $dir: $!";
while ( defined ($file = readdir(DIR)) ) {
next if $file =~ /^\.\.?/;
@files = glob("$edioldtmp_dir/*");
$ftpsub_rc=ftpsub();
print "return code= $ftpsub_rc\n";
if ( $ftpsub_rc == 0 ) { unlink( $file),
print log "$now-> File: $file\n:" };
print "files deleting\n";
};
sub ftpsub {
use Net::FTP;
$mode = "ascii";
my $ftp;
#@files = glob("$edioldtmp_dir/*");
$ftp = Net::FTP->new("sample.com", Port => 21, Debug => 1) || return(1);
$ftp->login("userid", "password") || return(1);
$ftp->cwd ("/INBOUND/EDI") || return(1);
foreach $file(@files) {
$ftp->ascii() if($mode eq "ascii");
$ftp->binary()if ($mode eq "binary");
$ftp ->put ($file) || return(1);
}
return (0);
$ftp->quit() || return(1);
};
closedir(EDIOLDTMP);
closedir(DIR);
close LOG;
"if ( $ftpsub_rc == 0 ) { unlink( $file),
===============
#!/usr/bin/perl
# The files are moved in batch mode.
my $now=localtime;
open(LOG, ">>/usr/local/cyclone/logs");
$edioldtmp_dir = "/local/ediold/tmp";
opendir(DIR, $edioldtmp_dir);
print "Open dir\n";
opendir(EDIOLDTMP, $edioldtmp_dir) or die "Can't open $dir: $!";
while ( defined ($file = readdir(DIR)) ) {
next if $file =~ /^\.\.?/;
@files = glob("$edioldtmp_dir/*");
$ftpsub_rc=ftpsub();
print "return code= $ftpsub_rc\n";
if ( $ftpsub_rc == 0 ) { unlink( $file),
print log "$now-> File: $file\n:" };
print "files deleting\n";
};
sub ftpsub {
use Net::FTP;
$mode = "ascii";
my $ftp;
#@files = glob("$edioldtmp_dir/*");
$ftp = Net::FTP->new("sample.com", Port => 21, Debug => 1) || return(1);
$ftp->login("userid", "password") || return(1);
$ftp->cwd ("/INBOUND/EDI") || return(1);
foreach $file(@files) {
$ftp->ascii() if($mode eq "ascii");
$ftp->binary()if ($mode eq "binary");
$ftp ->put ($file) || return(1);
}
return (0);
$ftp->quit() || return(1);
};
closedir(EDIOLDTMP);
closedir(DIR);
close LOG;