Net::FTP->problem with put

Net::FTP->problem with put

am 28.02.2006 08:11:13 von chinzi

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

Re: Net::FTP->problem with put

am 28.02.2006 08:17:08 von Michael Greb

In article <1141110673.463476.18230@i40g2000cwc.googlegroups.com>,
"chinzi" wrote:

> 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

Re: Net::FTP->problem with put

am 28.02.2006 08:31:16 von Sisyphus

"chinzi" wrote in message
news:1141110673.463476.18230@i40g2000cwc.googlegroups.com...
> 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

Re: Net::FTP->problem with put

am 28.02.2006 09:32:39 von chinzi

#!/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 ..

Re: Net::FTP->problem with put

am 28.02.2006 10:04:00 von Michael Greb

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.

In article <1141115559.066563.80320@e56g2000cwe.googlegroups.com>,
"chinzi" wrote:

> #!/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

Re: Net::FTP->problem with put

am 28.02.2006 10:27:02 von Sisyphus

"chinzi" wrote in message > #!/usr/bin/perl -w

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

In addition to Michael's suggestions, make that:

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

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

So this will place you in the '/etc/init.d/' directory. Is there such a
directory ?

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

That will try to put a file named 'start' from the local current directory,
into the remote current directory - and save it there as 'startup'.

Is there a file named 'start' in the local current directory ? If so (and if
the directory '/etc/init.d/' exists), then you can expect to see a file
named 'startup' in the remote directory '/etc/init.d/' and 'startup' should
be identical to 'start'.

Cheers,
Rob

Re: Net::FTP->problem with put

am 28.02.2006 10:51:25 von chinzi

hey Michael Greb

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

i used this and i am getting the error as Cannot create file ..

Re: Net::FTP->problem with put

am 28.02.2006 10:54:07 von chinzi

hey Michael Greb

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

i used this and i am getting the error as Cannot create file ..

Re: Net::FTP->problem with put

am 28.02.2006 11:07:02 von Michael Greb

In article <1141120447.024812.247780@z34g2000cwc.googlegroups.com>,
"chinzi" wrote:

> hey Michael Greb
>
> > $ftp->put('start', 'startup')
> > or die 'Put failed: ', $ftp->message, "\n";
>
> i used this and i am getting the error as Cannot create file ..

Does the user you are logging in to the ftp server as have permission to
write to /etc/init.d/?

--
Michael
michael@thegrebs.com

Re: Net::FTP->problem with put

am 28.02.2006 11:22:58 von chinzi

> Does the user you are logging in to the ftp server as have permission to
> write to /etc/init.d/?

how do i check that??? it might be the problem bcoz i am putting the
file in the home of the user it is being able to transfer ..

Re: Net::FTP->problem with put

am 28.02.2006 11:53:29 von Michael Greb

In article <1141122178.770518.192760@v46g2000cwv.googlegroups.com>,
"chinzi" wrote:

> > Does the user you are logging in to the ftp server as have permission to
> > write to /etc/init.d/?
>
> how do i check that??? it might be the problem bcoz i am putting the
> file in the home of the user it is being able to transfer ..

You are trimming a bit too much of the quoted text, you want to keep the
line that says who you are replying to at least.

I'm not quite sure I understand what you mean by "i am putting the file
in the home of the user it is being able to transfer". The issue would
be wether the username you are using for the ftp connection has access
to write to /etc/init.d/ on the ftp server, since this is the directory
you are trying to upload to. What do the ftp server's logs say about
the connection?

--
Michael
michael@thegrebs.com

Re: Net::FTP->problem with put

am 28.02.2006 12:14:35 von chinzi

hey Michael ..

>The issue would
>be wether the username you are using for the ftp connection has access
>to write to /etc/init.d/ on the ftp server

--- how do i check that the user has the access to write or nt ..


>What do the ftp server's logs say about
>the connection?

---where do i find the ftp's log files ..

Re: Net::FTP->problem with put

am 28.02.2006 12:28:10 von greger

Michael Greb wrote:

> In article <1141122178.770518.192760@v46g2000cwv.googlegroups.com>,
> "chinzi" wrote:
>
>> > Does the user you are logging in to the ftp server as have permission
>> > to write to /etc/init.d/?
>>
>> how do i check that??? it might be the problem bcoz i am putting the
>> file in the home of the user it is being able to transfer ..
>
> You are trimming a bit too much of the quoted text, you want to keep the
> line that says who you are replying to at least.
>
> I'm not quite sure I understand what you mean by "i am putting the file
> in the home of the user it is being able to transfer". The issue would
> be wether the username you are using for the ftp connection has access
> to write to /etc/init.d/ on the ftp server, since this is the directory
> you are trying to upload to. What do the ftp server's logs say about
> the connection?
>
hello
it depends, if you log on someplace with anonymous and some pass( like your
email adress) then by default I'd assume that you have read permissions but
not put permissions, as your error messsage says the user you are trying
wiht has no write permissions on the server you connect to. This is
something you have to configure on the server( if that is in your hands) or
then use another user and pass which has actually write permissions there.

Greger
--
www.gregerhaga.net

Re: Net::FTP->problem with put

am 01.03.2006 21:53:40 von 1usa

"chinzi" wrote in news:1141125275.845696.37080
@i40g2000cwc.googlegroups.com:

> hey Michael ..

Please do not strip attributions.

>>The issue would
>>be wether the username you are using for the ftp connection has access
>>to write to /etc/init.d/ on the ftp server
>
> --- how do i check that the user has the access to write or nt ..

By logging on to the remote system. On the other hand, it is safe to
assume at this point that such access rights are not granted to the user
id under which you are logging on.

This maybe true even if the user would have such access rights when
logged in to a shell. After all, most ftp servers do not expose the
whole system to ftp users.

>>What do the ftp server's logs say about
>>the connection?
>
> ---where do i find the ftp's log files ..

On the server.

Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines .html

Re: Net::FTP->problem with put

am 03.03.2006 08:16:37 von chinzi

>>On the server.

what i meant by my question was where on the server??????
i want the exact path ...

Re: Net::FTP->problem with put

am 03.03.2006 11:32:56 von Michael Greb

In article <1141370197.481223.157010@v46g2000cwv.googlegroups.com>,
"chinzi" wrote:

> >>On the server.
>
> what i meant by my question was where on the server??????
> i want the exact path ...

That's going to depend on the ftpd software used and how it is
configured but this is comp.lang.perl.modules not an ftp server group.

--
Michael
michael@thegrebs.com

Re: Net::FTP->problem with put

am 05.04.2006 16:04:52 von Kenneth Tomiak

Forgive me for not responding to one of the later posts, I thought some
higher up level might save someone wanting similar help some time.

Nothing never happens, something always happens. You may not like the
something, but something always happens. Even a timeout or null response is
something. 'Can't create file' is a something message telling you something,
not nothing.

From my 25+ years of programming I learned when you try to script an action,
it is always best to test your script by replicating something you can
actually do. So instead of trying to force perl to ftp a file to some
server, start a client ftp program and login with the userid and password
your script is going to use. Issue the commands your script is going to do.
If you can't do it, your script can't do it. Don't test something different
than what your script is expected to do. All too many people test to some
other server with some other userid and then say the script is the problem.
I believe a standard ftp command is 'ls', which may take a parameter like
'-a' to show all information. Including permissions. Even non-*nix systems
are known to reply with permissions. If you can't do it from an ftp client
then it isn't a problem with your perl code.


"chinzi" wrote in message
news:1141110673.463476.18230@i40g2000cwc.googlegroups.com...
> 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
>