in reply to FTP single file to remote server

ponder,

I understand that you are just starting out with Perl (perhaps this is your first programming experience). One thing I would like to point out (zentara has already made you aware of potential confusion caused by the name of your script) is that you are not checking for failures, and assuming everything worked fine. Take a look at this slight reworking of your code:
#!/usr/bin/perl #---------------------------- #FTP's single file to servage #By Benjamin Ruston #benjamin@digitalwombat.com #Ponder@DALnet #28th November 2006 #------ #Usage: ./sftp ~/dog.jpg /www/public #./sftp filename remotelocation #------ use strict; use warnings; use Net::FTP; my $file = $ARGV[0]; my $rloc = $ARGV[1]; my $host = "ftp.host.here"; my $ftp = Net::FTP->new($host, Debug => 0) or die "Could not connect t +o host $host : $@" #Login and password need to be set here $ftp->login("username",'password') or die "Failed to log in ", $ftp->m +essage; $ftp->cwd($rloc) or die "Failed change working directory ", $ftp->mess +age; $ftp->put($file) or die "Failed to transfer file ", $ftp->message; $ftp->quit;

Note the addition of the use strict; use warnings; about the use Net::FTP line. For more info on why I added these lines read Use strict and warnings from the Tutorials section of this site.

Also note that I had added lines to display a message when an operation failed. In the event of a failure, your code would look to the user as though it had executed without any problems. Note that I have printed a message to the screen at each point the FTP operation could fail. The examples in the Net::FTP documentation inform you how to do this. The Tutorials section of this site is a great resource, and always read the module documentation.

Hope this helps.

Martin

Update: Fixed a couple of typos