On Wed, 07 Apr 2004 12:01:26 -0500, mlm45 wrote:
I am hoping to find a way to post a file to a remote web page in an
automatic way using a perl script on a Windows machine. I prefer not to
use FTP as I have to put passwords in the script. I'd also like to avoid
SMTP.
Is there a way to have a perl program send a local file to a remote
computer using http?
Thanks
Mark
I recently wrote something like that. Unfotunately, I use FTP.
Try something like this:
#!/usr/bin/perl -w
use Net::FTP;
use Cwd;
$Host = "ftp.whatever.com" ;
$User = "loginname" ;
$Pwrd = "password" ;
$Dir = "/www" ; # i.e. the target dir on the remote server
print "<p>\n\nConnecting to $Host " ;
$ftp = Net::FTP->new($Host, Debug => 0)
|| die "Cannot connect to '$Host' : '$@' " ;
print "<br>Logging in user '$User', and password ... " ;
$ftp -> login ($User, $Pwrd)
|| die "Cannot login ", $ftp->message ;
print " cwd to '$Dir', " ;
$ftp -> cwd ($Dir)
|| die "Cannot change dir to '$Dir'" ;
print "<br>Writing files : " ;
foreach $File (@FileList) {
$ftp -> put ($File)
|| die "Cannot put file ", $ftp->message ;
}
print "<br>Done. Logging out. " ;
$ftp -> quit ;
hth,
Arno Reuser