in reply to Capturing FTP output

Use IPC::Open2 or IPC::Open3 (core since perl 5) for that.

Replies are listed 'Best First'.
Re^2: Capturing FTP output
by wishartz (Beadle) on May 15, 2008 at 13:55 UTC
    Is this what you mean? Cannot get it too work
    my $pid = open2(\*READ, \*WRITE, "ftp -i -v -n" ); print WRITE "open $FTP_HOST\n"; print WRITE "quote USER $FTP_USER\n"; print WRITE "quote PASS $FTP_PASS\n"; print WRITE "cd $FTP_DIR\n"; print WRITE "FTP "bin\n"; print WRITE "get $FTP_FILE\n"; print WRITE "bye\n"; my @data = <READ> ;

      Your script as posted contains won't compile as it contains syntax errors. Your big problem, however, is that ftp, when not in interactive mode, doesn't write to anything to stdout. You won't know if anything goes wrong. Ftp will just exit without saying anything. So you'll need to check your files to see if the transfer actually took place.

      Caveat: tested on FreeBSD.


      s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}