Hello all,
I have a program that basically does an FTP get of a file from a server, deletes some stuff from the file and then does an FTP put to another server.
My script is working correctly but I would like to be able to print the FTP debug output to a logfile. Here is one of the FTP subroutines:
The debug output is being printed to STDOUT (I think) and I want it going to my logfile (filehandle OUT).
I even tried running the script and piping the output to a file to catch the debug output but it still prints to the console. I tried:
scriptname.pl 2>&1 > debug_file.txt
scriptname.pl > debug_file.txt
But it still only print to the console.
Any help is appreciated.
Nick
If at first you don't succeed, don't try skydiving.
I have a program that basically does an FTP get of a file from a server, deletes some stuff from the file and then does an FTP put to another server.
My script is working correctly but I would like to be able to print the FTP debug output to a logfile. Here is one of the FTP subroutines:
Code:
sub GetFTP
{
##########################################################################################
#
# This subroutine performs an FTP Get using the Net::FTP module
#
##########################################################################################
my $ftp_server = shift(@_);
my $sub_pass = shift(@_);
my $sub_uid = shift(@_);
my $sub_path = shift(@_);
my $sub_log = shift(@_);
print OUT "Beginning FTP Get from $ftp_server. Getting log $sub_log from path $sub_path\n";
# print OUT "FTP Debug output:\n\n";
my $ftp = Net::FTP->new("$ftp_server", Debug => 1, Timeout => 1300)
or die ("Cannot connect to $ftp_server: $@");
$ftp->login($sub_uid,$sub_pass)
or die ("Cannot login ", $ftp->message);
$ftp->cwd($sub_path)
or die("Cannot change working directory ", $ftp->message);
$ftp->get($sub_log)
or ErrorOut("get failed ", $ftp->message);
$ftp->quit;
print OUT "\nEnd FTP get from $ftp_server\n\n";
print "\n\n";
} # End sub GetFTP
The debug output is being printed to STDOUT (I think) and I want it going to my logfile (filehandle OUT).
I even tried running the script and piping the output to a file to catch the debug output but it still prints to the console. I tried:
scriptname.pl 2>&1 > debug_file.txt
scriptname.pl > debug_file.txt
But it still only print to the console.
Any help is appreciated.
Nick
If at first you don't succeed, don't try skydiving.