You might find this subroutine that I wrote of us. It's currently being run as a cronjob on one of our servers and just transfers files via FTP to another site...
use Net::FTP; $screen=1; # change to 0 for 'quiet' operation (ie no screen display) sub move_files { # moves a file by FTP to a remote site # Code by Richard Chiswell # http://www.beebware.com/ # Free usage, acknowledgements would be appreciated tho! my ($destination,$file)=@_; # destination is in the format username:password@ftp.example.com # file is the local full path name of the file to be transfered my ($username,$password,$host,$path,$ftp); my ($results,$logfile,$movedlog); # first let's split the destination information apart $destination=~/^([^\:]+)\:([^\@]+)\@([^\/]+)\/(.*)/; ($username,$password,$host,$path)=($1,$2,$3,$4); $path="/".$path; print "Destination:$destination\n" if $screen; print "Login as $username (password: $password) onto:\n" if $screen; print " Host: $host\n" if $screen; print " Path: $path\n" if $screen; $logfile.="Login as $username (password: $password) onto:\n"; $logfile.=" Host: $host\n Path: $path\n"; $logfile.=" Time: ".&show_time(time())."\n\n"; if (length($host)>1) { $ftp=Net::FTP->new($host,Debug=>0); if (!defined($ftp)) { print "* Unable to connect to FTP server:\n $@\n" if $screen; $logfile.= "*********************************************\n"; $logfile.="* UNABLE TO CONNECT TO FTPSERVER! *\n"; $logfile.="$@\n"; } else { $logfile.="Connected\n"; $results=$ftp->login($username,$password); if (!$results) { print "* Unable to login to FTP server:\n" if $screen; print $ftp->message()."\n" if $screen; $logfile.="********************************************\n"; $logfile.="* UNABLE TO LOGIN TO FTP SERVER! *\n"; $logfile.=$ftp->message()."\n"; } else { print "Logged in\n" if $screen; $logfile.="Successfully logged in\n"; $ftp->cwd($path); print "Changed to $path\n ".$ftp->message()."\n" if $screen; print "Current path is ".$ftp->pwd()."\n" if $screen; $logfile.="Path: ".$ftp->pwd()."\n"; $ftp->hash(1024); $ftp->binary(); $results=$ftp->put($file); if (!$results) { print "* Unable to transfer: file\n" if $screen; print $ftp->message()."\n" if $screen; $logfile.="* Unable to transfer:$file\n"; $logfile.=" Message:".$ftp->message()."\n"; } else { $movedlog.="Moved $file\n";unlink $file; $logfile.="Moved $file\n"; } $ftp->quit; } } $movedlog="These files have been moved to\n"; $movedlog.="$destination\n\n$movedlog\n"; } else { print "Unable to read FTP details!\n" if $screen; } return "$movedlog\n\n*****************************\n\n$logfile"; print "DONE!\n" if $screen; }
So for example, to transfer the file /temp/file.txt to ftp.example.com with the login username of 'user' and the password 'pass', just call $log=&move_files("user:pass@ftp.example.com","/temp/file.txt");. The $log can then be either emailed (as we have set it up) or just stored in a log file or disgarded. I hope it helps.

In reply to Re: Image upload by beebware
in thread Image upload by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.