Automating ftp using Perl



Posted by lionel319 @ Wed 14 May, 08, 02:03PM under Work



Ever experienced the pain of  doing a put / get for each and every file / folder one by one when you want to transfer stuff across network? Well, worry no more. Here's something simple that you can do to automate the File Transferring Protocol process quick and easy, All you need is a perl module call Net::FTP.




#!/apps/perl/bin/perl -w

use Net::FTP;

$host = 'www.javtalk.com';
$username = 'adrian';
$password = 'mutumbo';

$ftp = Net::FTP->new($host, Debug=>0) || die "Can't connect to $hostn";
$ftp->login($username, $password) || die "Can't loginn";


### To get (download) a file from the server, use the get() command
### To put (upload) a file to the server, use the put() command

$ftp->get( "water.avi" ) ||  die "Can't GET.  $ftp->messagen";



Have fun playing with PERL
^_^





leave me a message
Name
Enter the Code below
(only contain alphabets):
Website
Rating Worst Best

lionel319 @ Wed 14-05-08 05:03PM
As a side note, here's how you do the ftp thingie in csh, thanks to pcnuts.


echo "open ftp.javtalk


user adrian motumbo


cd wetwet


binary


prompt n


get water.avi


quit" |ftp -n -i -v |tee ftp.log



Search

Back to TextMalaysia Home
TextMalaysia.com is Powered by TinyMCE

Subscribe to this blog
RSS Feed for lionel.textmalaysia.com
Categories
Archive



© TextMalaysia is a free blogging service powered by WSATP