Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Capturing FTP output

by starbolin (Hermit)
on May 15, 2008 at 21:45 UTC ( [id://686817]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Capturing FTP output
in thread Capturing FTP output

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.


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://686817]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-03-29 00:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found