Click here to get back home

Net::FTP->problem with put

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Net::FTP->problem with put chinzi 02-28-2006
Posted by chinzi on February 28, 2006, 2:11 am
Please log in for more thread options


hey i am trying to transfer a file .. i have used Net::Ftp module ..
login .. pwd() etc are all working fine but i am nt able to put the
file .. nthing is happening


Posted by Michael Greb on February 28, 2006, 2:17 am
Please log in for more thread options



> hey i am trying to transfer a file .. i have used Net::Ftp module ..
> login .. pwd() etc are all working fine but i am nt able to put the
> file .. nthing is happening

Can you post an example of some code you have tried that didn't work?

Michael

Posted by Sisyphus on February 28, 2006, 2:31 am
Please log in for more thread options



> hey i am trying to transfer a file .. i have used Net::Ftp module ..
> login .. pwd() etc are all working fine but i am nt able to put the
> file .. nthing is happening
>

Try setting DEBUG=>1 in the constructor. That might give a hint as to why
"nothing is happening".

Other than that, provide a complete minimal script so we can see exactly
what you're doing. Don't put your real username and password in that script.
There's also no need to provide the actual server name either - but
everything else should be exactly as you're doing it (ie copy'n'paste).

Cheers,
Rob



Posted by chinzi on February 28, 2006, 3:32 am
Please log in for more thread options


#!/usr/bin/perl -w


use Net::FTP;

$ftp=Net::FTP->new($host)
or die("cannot establish ftp connection with $host");


$ftp->login("","");


$ftp->cwd("/");
$ftp->cwd("/etc/init.d");


@lines=$ftp->pwd();
print "\n\nCurrent Directory is @lines"; // this gives the correct
current directory


$ftp->put("start","startup");


i have typed this code .. if i am using get i.e. getting a file from
the remote machine it is working properly ..


Posted by Michael Greb on February 28, 2006, 4:04 am
Please log in for more thread options


Notice how my reply quotes your message and says which message I am
replying too? You can do this by clicking the options or details link
at the top and then selecting reply there.


> #!/usr/bin/perl -w

use strict; # you were missing this
use warnings; # it's better to use warnings rather
# then call perl with -w

> use Net::FTP;
>
> $ftp=Net::FTP->new($host)
> or die("cannot establish ftp connection with $host");
>
> $ftp->login("","");
>
> $ftp->cwd("/");
> $ftp->cwd("/etc/init.d");
>
> @lines=$ftp->pwd();
> print "\n\nCurrent Directory is @lines"; // this gives the correct
> current directory

I'm not very familiar with this module as I've never used it but
wouldn't a scalar be more appropriate? Does $ftp->pwd() actually return
a list? Also, # is the comment character in perl, not //

>
> $ftp->put("start","startup");

Replace this with:

$ftp->put('start', 'startup')
or die 'Put failed: ', $ftp->message, "\n";

This should give you some useful diagnostic output.

> i have typed this code .. if i am using get i.e. getting a file from
> the remote machine it is working properly ..

--
Michael
michael@thegrebs.com


Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap