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

Re: Net::FTP and putting errors to STDOUT???

by ikegami (Patriarch)
on Sep 17, 2004 at 17:27 UTC ( [id://391849]=note: print w/replies, xml ) Need Help??


in reply to Net::FTP and putting errors to STDOUT???

This might do the trick:

sub ftpme { my $remotehost="ftp.foo.com"; my $remotedir="archive"; my $user="xxxxx"; my $pass="xxxxxx"; my $data=$scratchtps; local *FTPLOG; open(FTPLOG, ">>/usr/local/log/ftp_IrMt_scratchtapes.l +og") or die("Can't open log file"); my $ftp = Net::FTP->new($remotehost, Debug => 10) or do { print FTPLOG "Cannot connect to $remotehost: I +ronMt: $!"; die(); }; $ftp->login($user, $pass) or do { print FTPLOG "Login failed!: $!"; die(); }; $ftp->ascii(); $ftp->cwd($remotedir); $ftp->put($data) or do { print FTPLOG "FTP put to IrMt failed!: $!"; di +e(); }; $ftp->quit; }

Replies are listed 'Best First'.
Re^2: Net::FTP and putting errors to STDOUT???
by drock (Beadle) on Sep 17, 2004 at 17:39 UTC
    cool...thanks! What is the * next to the FTP filehandle represent?

      Similiar to $ = scalar, @ = array, % = hash and & = code, there is a -what's-the-word- for symbol table entries and file handles: *.

      print("1\n"); open(HANDLE, '<', 'lines.txt') or die("!1\n"); print(scalar(<HANDLE>)); close(HANDLE); print("\n"); print("2\n"); $h = *HANDLE; open($h, '<', 'lines.txt') or die("!2\n"); print(scalar(<HANDLE>)); print(scalar(<$h>)); close($h); print("\n"); print("3\n"); $h = \*HANDLE; open($h, '<', 'lines.txt') or die("!3\n"); print(scalar(<HANDLE>)); print(scalar(<$h>)); close($h); print("\n");

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-19 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found