Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't take log of 0

Status
Not open for further replies.

rozzay

Programmer
Jan 3, 2002
142
US
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;
 
First issue is that you are joining that and the next statement with the comma at the end of that line. Why?
You probably meant to use a semicolon.
Second issue is that you open a filehandle called "LOG" but try printing to "log". The case is important. Fix that print statement by replacing "log" with "LOG".
There may be other issues but I haven't looked at your code any further than that.


Trojan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top