in reply to Re: perl ftp
in thread perl ftp

Hi friends, please have a look at the data that i put in the mail.it contains details of the output that is sent to the STDOUT and there is no error in the script no in the output. All i want is to send the same output to some logfile. but when i tried to redirect nothing went in. I got this out put after i set the Debug option as 1 in the ftp connection. Please advice.i need the whole output to be logged. Thanks Veera

Replies are listed 'Best First'.
Re^3: perl ftp
by inman (Curate) on May 20, 2005 at 15:42 UTC
    Try the variations in my post above. Your script will use both STDOUT and STDERR. Both of these normally send output to the console where it all appears the same. The Net::FTP debug code is sent to STDERR rather than STDOUT.

    The simple redirection perl script.pl >file will send only STDOUT to the file.

    perl script.pl 2>file will send the STDERR to the file. The 2> selects STDERR as the file handle.

    This command redirects both STDOUT and STDERR to a file. perl script.pl >file 2>&1

      Hi inman , IT WORKS. thanks a lot for your help. i got what i wanted. i used the command perl script.pl 2>file thanks a lot again Bye Veera
      Hi Dear, i tried the options that you mentioned but i didnt get what i want.Any other possible way ? Please help this is what i am getting on the STDOUT ====================================================== Net::FTP=GLOB(0x4024198c)<<< 220 nti261 FTP server (Version 1.1.214.4(PHNE_30990) Mon Nov 2:47:12 GMT 2004) ready. Net::FTP=GLOB(0x4024198c)>>> user veerams Net::FTP=GLOB(0x4024198c)<<< 331 Password required for veerams. Net::FTP=GLOB(0x4024198c)>>> PASS .... Net::FTP=GLOB(0x4024198c)<<< 230 User veerams logged in. User veerams logged in. |230 Net::FTP=GLOB(0x4024198c)>>> CWD ~/working Net::FTP=GLOB(0x4024198c)<<< 250 CWD command successful. CWD command successful. |250 Net::FTP=GLOB(0x4024198c)>>> PORT 10,201,15,62,228,180 Net::FTP=GLOB(0x4024198c)<<< 200 PORT command successful. Net::FTP=GLOB(0x4024198c)>>> STOR 1 Net::FTP=GLOB(0x4024198c)<<< 150 Opening ASCII mode data connection for 1. Net::FTP=GLOB(0x4024198c)<<< 226 Transfer complete. . .. 1 2 a b c d f s zOpening ASCII mode data connection for 1. Transfer complete. |226 ===================================== and this is what is being put in the logfile ================================================ User veerams logged in. |230 CWD command successful. |250 Opening ASCII mode data connection for 1. Transfer complete. |226 /home/veerams/source/1 Opening ASCII mode data connection for 2. Transfer complete. |226 /home/veerams/source/2 Opening ASCII mode data connection for a. Transfer complete. |226 ======================================= i want the whole output that i am getting on the STDOUT into the logfile and not the one that i am getting now Any way out ? please help Thanks in advance Veera
        srini_veera, what platform are you running this under? Windows? Linux? Solaris? HP-UX? And more specifically what shell? sh? csh? bash? ksh? The output should be going to STDERR not STDOUT. It's the shell syntax that you need to properly construct (and thats different for each shell) and we cannot help unless you tell us what shell you're running under.

        If you don't want to be bothered with shell syntax, just close STDERR and re-open it to your log:

        !/usr/bin/perl -w use strict; use Net::FTP; # Capture STDERR close( STDERR ); open( STDERR, ">mylog.txt" ); my $ftp = Net::FTP->new("some.host.name", Debug => 1) or die "Cannot connect to some.host.name: $@"; $ftp->login("ftp",'foo@bar.com') or die "Cannot login ", $ftp->message; $ftp->cwd("/") or die "Cannot change working directory ", $ftp->message; $ftp->get("filename") or die "get failed ", $ftp->message; $ftp->quit;

        -derby