FTP file upload using perl from local system -
requirement:
i want create script upload files local system ftp server in using perl.
sample code:
use net::ftp; $ftp = net::ftp->new("some.host.name", debug => 0) or die "cannot connect some.host.name: $@"; $ftp->login("anonymous",'-anonymous@') or die "cannot login ", $ftp->message; $ftp->cwd("/pub") or die "cannot change working directory ", $ftp->message; $ftp->get("that.file") or die "get failed ", $ftp->message; $ftp->quit;
p.s: newbie in perl.
you can try code working fine me
use strict; use warnings; use net::ftp; ($ftp, $host, $user, $pass, $dir, $fpath); $host = ""; $user = ""; $pass = ""; $dir = ""; $fpath = ""; $ftp = net::ftp->new($host, debug => 0); $ftp->login($user, $pass) || die $ftp->message; $ftp->cwd($dir); $ftp->put($fpath) || die $ftp->message; $ftp->quit; print $ftp->message;
Comments
Post a Comment