O wise ones and those seeking wisdom...

I have been trying for a couple of weeks now to get the put function working in a subscript using Net::FTP. Here is the code:

use Net::FTP; my $ftp; $ftp = Net::FTP->new($ftp_server, Debug => 1)or die "Cannot connect"; $ftp->login($login,$password)or die $ftp->message; $ftp->pwd or die $ftp->message; $ftp->cwd($upload_to_dir) or die $ftp->message; warn "Failed to set binary mode\n" unless $ftp->binary(); print "Uploading $input_file...<br>"; $ftp->put ( $input_file, $new_file_name ) or die "did not upload"; $ftp->quit;

The file never uploads at the $ftp->put line - there is only death.

My first guess is that the file path is formatted wrong for the $input_file variable. My current value and format is: e:\test\picture.jpg

I have also tried
e:/test/picture.jpg
e://test//picture.jpg
E://test//picture.jpg

and a variety of other such things but I haven't got it to work. Does anyone know what the correct format for a path for that arguement should be?

Do I need to somehow direct the script to a specific directory on the local computer first (similar to how $ftp->cwd() is used to get to the proper directory on the remote host)?

My value for $new_file_name is test.jpg.

I have tested other things such as creating a directory using this script and I can do that, so I believe I am correctly logged in by FTP and in the proper directory.

I have talked to my host to see that Net::FTP is correctly installed and they assure me that it is, and even reinstalled it to be sure. I have the log of that re-installation if anyone things it would be useful.

I noticed on my server in the list of Installed Perl Modules that there appears to be two copies of Net::FTP - could that be causing my problem, if one is defective??? If that is the case, how do we remove one?

Could it be that the Net::FTP program is not compatible with my server (basic Linux) or its firewall? I seem to have no trouble ftping with the same username and password via ws_ftp pro.

Your insight and wisdom is greatly appreciated!

-Matt :)

Appended Update:

Many thanks to the brothers and sisters here at the monastery, who have enlightened my path! You have solved my problem - and the solution (for those who may have a similar problem) is that that is not what Net::FTP is designed to do. I don't have an answer yet for how to do what I am want to do, but I'll check in a different direction and I'm sure with Perl a way will be found!

-Matt :)

In reply to Struggles with Put in Net::FTP by mchiles

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.