It's Saturday night and I'm feeling bored :)
use strict; use warnings; use File::Temp 'tempfile'; use Net::FTP; use constant HOSTNAME => 'ftp.example.com'; use constant USERNAME => 'grinder'; use constant PASSWORD => 'seekret'; my $msg = <STDIN>; my ($out, $file) = tempfile('msg_XXXXXXXX', SUFFIX => '.txt'); print $out $msg or die "Cannot print to $file: $!\n"; close $out or die "Cannot close $file: $!\n"; my $host = Net::FTP->new(HOSTNAME) or die "Cannot connect to ", HOSTNAME, ": $!\n"; $host->login(USERNAME, PASSWORD) or die "login error: ", $host->message, $/; $host->put($file) or die "cannot put $file: ", $host->message, $/; $host->quit; unlink $file;
I haven't actually tested this, but I see no reason why it shouldn't work. Have fun!
• another intruder with the mooring in the heart of the Perl
In reply to Re: Send/Upload some text as *.TXT on FTP
by grinder
in thread Send/Upload some text as *.TXT on FTP
by xoddam
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |