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.
Your script worked for me after commenting out a line with a syntax error.
#!/usr/bin/perl use strict; use warnings; use IPC::Open2; my $FTP_HOST = 'glarch'; my $FTP_USER = 'JRUser'; my $FTP_PASS = 'quux'; my $FTP_DIR = '~/src'; my $FTP_FILE = 'foobar'; my $pid = open2(\*READ, \*WRITE, "ftp -n -i -v " ); 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> ;
Caveat: tested on FreeBSD.
In reply to Re^3: Capturing FTP output
by starbolin
in thread Capturing FTP output
by wishartz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |