> -----Original Message----- > From: Chas. Owens [mailto:[EMAIL PROTECTED] > Sent: Wednesday, April 09, 2008 12:33 > To: Wagner, David --- Senior Programmer Analyst --- WGO > Cc: beginners@perl.org > Subject: Re: Example of FTP w/o Input file? Is it possible to > do or not? > > On Wed, Apr 9, 2008 at 1:56 PM, Wagner, David --- Senior Programmer > Analyst --- WGO <[EMAIL PROTECTED]> wrote: > > I have a hash which contains for each entry the > email which I > > need to ftp to a particular location with a specified name. I could > > write out the file and then do the ftp. But since I have > the necessary > > data in an audittrail report, I was wondering if I can ftp from a > > variable using ftp commands? > > > > I took a look at the doc on Net::FTP, but nothing > stood out and > > did not find an example. > snip > > I don't fully understand what you desire to do. It sounds like you > wish to FTP to a machine using a user and password retrieve by the > Perl program (that fact that is stored in a hash is irrelevant) and > maintain a log of the fact that you are making this FTP connection.
No. I want to do a put of a file, but without having to write the file first and then doing put(Filein,fileout). I could write out the 60 plus files each time, but I am trying to get the data to a file on the remote server without having a file on the input side. Understand? Thanks. Wags ;) > This is simple in Perl: > > #warning untested code as I don't maintain and FTP servers anymore > (they are insecure, use scp or sftp instead) > #!/usr/bin/perl > > use strict; > use warnings; > use Net::FTP; > use POSIX; > > sub log { > my $log = shift; > print $log map { strftime "%Y-%m-%d %H:%M:%S $_\n", > localtime() } @_; > } > > my $host = "localhost"; > my $user = "foo"; > my $pass = "bar"; > > open my $log, ">>", "path/to/audit.log" > or die "could not open audit log: $!"; > > $SIG{__DIE__} = sub { log($log, shift) }; > > my $ftp = Net::FTP->new($host) > or die "Cannot connect to $host: $@"; > > log($log, "connected to $host"); > > $ftp->login($user, $pass) > or die "Cannot login as $user: ", $ftp->message; > > log($log, "logged in as $user"); > > #do ftp stuff you need to do, logging as you go > > $ftp->quit; > > log($log, "logged out as $user on $host"); > > -- > Chas. Owens > wonkden.net > The most important skill a programmer can have is the ability to read. > ********************************************************************** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. ********************************************************************** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/