Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

...That's how perlmonks works [Re: Re: Re: trouble while ftping through Perl Script]

by bronto (Priest)
on Apr 29, 2004 at 13:38 UTC ( [id://349126]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: trouble while ftping through Perl Script
in thread trouble while ftping through Perl Script

Provide problems, and we (try to) provide solutions, that's how perlmonks works. If you just told us your problems with Net::FTP at your first post, everyone had benefits out of it: you would have had the solution, and others would not have wasted their time trying to guess what the problem was and how to solve it

Update: By the way, when you are going to use objects in Perl it's always better to check that you really have one before trying to use it. I mean:

use Net::FTP; # this is wrong, because you cwd without checking # if $ftp is really an object or it is undef # (new() failed) $ftp = Net::FTP->new("some.host.name", Debug => 0) ; $ftp->cwd("/pub") ; # This is right instead, and it comes straight from # Net::FTP's documentation # See how every method call is checked for success $ftp = Net::FTP->new("some.host.name", Debug => 0) or die "Cannot connect to some.host.name: $@"; $ftp->login("anonymous",'-anonymous@') or die "Cannot login ", $ftp->message; $ftp->cwd("/pub") or die "Cannot change working directory ", $ftp->message; $ftp->get("that.file") or die "get failed ", $ftp->message; $ftp->quit;

Ciao
--bronto


The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway).
--John M. Dlugosz
  • Comment on ...That's how perlmonks works [Re: Re: Re: trouble while ftping through Perl Script]
  • Download Code

Replies are listed 'Best First'.
Re: ...That's how perlmonks works [Re: Re: Re: trouble while ftping through Perl Script]
by shilpam (Sexton) on Apr 30, 2004 at 04:58 UTC
    I had tried that too. I gives me an error message: Cannot login Login incorrect.
    I know the userid and password are correct....I've tested them directly. Just one doubt, the password contains some back slashes and $ sign. Can that be a problem? But, I am enclosing the password in quotes, so that should not be problem....??? My code is:
    use Net::FTP; my $ftp = Net::FTP->new("ftp.server.com", Debug => 0) or die "Cannot c +onnect to some.host.name: $@"; my $username = 'username'; my $password = 'pa\ss\wor$d$'; $ftp->login($username,$password) or die "Cannot login ", $ftp->message +; $ftp->cwd("/files") or die "Cannot change working directory ", $ftp->m +essage; $ftp->ls("/files") or die "get failed ", $ftp->message; $ftp->quit;
      Why not just apply some simple trouble shooting. Eliminate the password issue (if possible):
    • change the password for that user to something that doesn't have \'s or $'s in it long enough to test your script.
    • or try another user that does not have special charaters in the password.

      Plankton: 1% Evil, 99% Hot Gas.
        :-( The problem is - I cannot change the password...and there is only one userid that I can use to connect to this server.
        There is one thing I noticed....
        From the command prompt, if I try to login through Method1, it allows me to login whereas if I try to login through Method2, it gives me the same error message - Login incorrect.
        Any idea why this happens?
        Method 1 (WORKING)
        ftp -n open ftp.servername.com user username P\$a\$ss\$ >> 230 User username logged in. Access restrictions apply.
        Method 2 (NOT WORKING)
        ftp -n open ftp.servername.com user username >> 331 Password required for username I enter the same password i.e. P\$a\$ss\$ I get the error message >> 530 Login incorrect. Login failed.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://349126]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-19 16:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found