vaevictus has asked for the wisdom of the Perl Monks concerning the following question:
I was searching through the categorize Q&A, and mccormi asked a question that was a problem i had given up on a while back.
I'm not sure whether the problem is related to my ignorance or the module, but here's what i've discovered:
Net::FTP doesn't support any sort of variable uploads, just named files, and filehandles.
With the objective being to upload without using a file on the network, (useful for me, for example, when i want to upload a zipped (tgz'd) backup of a filesystem, too large to write to disk first),
my first line of thought was "hmm... it takes filehandles, see if STDIN works"... and it does:
$ftp = Net::FTP->new($destserv) || die "error connecting\n"; $ftp->login($destuser,$destpass); $ftp->binary(); $ftp->put(*STDIN,$remotefile) or die "error uploading\n"; $ftp->quit();
This will solve the issue at hand, by allowing a first script to pipe data into the STDIN of this script, to upload data without a file. However, I don't see why this has to be written with two processes. So, my second line of thought was "hmmm... it takes filehandles, use tie"... So, using IO::Scalar I wrote this:
my $data="FOOBAR"; tie *FOO, 'IO::Scalar',\$data; $ftp = Net::FTP->new($destserv) || die "error connecting\n"; $ftp->login($destuser,$destpass); $ftp->binary(); $ftp->put(*FOO,"remotelogfile") or die "error uploading\n"; $ftp->quit();
and while this scalar works for me as a FILE with normal filehandle usage,
while (<FOO>){print $_;} print FOO "hi";
in this particular module, i get the following error:
Cannot open Local file *main::FOO: No such file or directory
at ./netftpcgi.pl line 18
error uploading
This leads me to believe that for some reason, *main::FOO is different than *main::STDIN and that Net::FTP can tell. If anyone would help me with my logic, I'd appreciate it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Inconsistancy within Net::FTP?
by btrott (Parson) on Aug 23, 2000 at 23:34 UTC | |
by tilly (Archbishop) on Aug 23, 2000 at 23:38 UTC | |
by btrott (Parson) on Aug 23, 2000 at 23:45 UTC | |
|
Re: Inconsistancy within Net::FTP?
by rdw (Curate) on Aug 24, 2000 at 12:50 UTC | |
by merlyn (Sage) on Aug 24, 2000 at 17:39 UTC | |
by rdw (Curate) on Aug 24, 2000 at 19:07 UTC | |
|
Re (tilly) 1: Inconsistancy within Net::FTP?
by tilly (Archbishop) on Aug 23, 2000 at 23:30 UTC |