Morning,
I am trying to unlink(delete files) after ftp a list of files successfully to another server. I tried doing so when I receive a good return code for ftping the files
but receive an error message of "Can't return outside a subroutine at cyclone_ob_GIS_2.pl line 31." Your help is appreciated.
=========================================
#!/usr/bin/perl
# The files are moved in batch mode.
my $now=localtime;
open(LOG, ">>/usr/local/cyclone/logs");
$edioldtmp_dir = "test/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 =~ /^\.\.?/;
}
use Net::FTP;
$mode = "ascii";
@files = glob("$edioldtmp_dir/*");
$ftp = Net::FTP->new("test.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);
}
$ftp->quit() || return(1);
if (return == 0) {unlink ( $file@files),
print log "$now-> File: $file\n:"};
closedir(EDIOLDTMP);
closedir(DIR);
close LOG;
I am trying to unlink(delete files) after ftp a list of files successfully to another server. I tried doing so when I receive a good return code for ftping the files
but receive an error message of "Can't return outside a subroutine at cyclone_ob_GIS_2.pl line 31." Your help is appreciated.
=========================================
#!/usr/bin/perl
# The files are moved in batch mode.
my $now=localtime;
open(LOG, ">>/usr/local/cyclone/logs");
$edioldtmp_dir = "test/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 =~ /^\.\.?/;
}
use Net::FTP;
$mode = "ascii";
@files = glob("$edioldtmp_dir/*");
$ftp = Net::FTP->new("test.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);
}
$ftp->quit() || return(1);
if (return == 0) {unlink ( $file@files),
print log "$now-> File: $file\n:"};
closedir(EDIOLDTMP);
closedir(DIR);
close LOG;