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

In reply to Re: FTP single file to remote server by marto
in thread FTP single file to remote server by ponder

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.