Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Accessing FTP server using Net::FTP with any username and password

by vin.hephaistion (Initiate)
on Apr 18, 2013 at 04:45 UTC ( #1029255=perlquestion: print w/replies, xml ) Need Help??

vin.hephaistion has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I am using Net::FTP module to access the FTP server which is configured by me itself on another machine. I have configured the FTP server for anonymous access as well as authorized access. Just to understand the module functioning, i used a list of username and password to try out on my file server Wrote the following code trying combinations of username and password:

eval { $ftp = Net::FTP->new($in, Debug => 0); $ftp->login($username,$password); }; if(!($@)) { print SLOG "Connected FTP: for $username and $password \n"; }

It is giving me... Connected to FTP: for all combinations of the username and password.

Note: 1) I want to notify that the FTP server has anonymous login. 2) I don't want it to be accessed by any other username and password except for the valid ones using Net::FTP

  • Comment on Accessing FTP server using Net::FTP with any username and password
  • Download Code

Replies are listed 'Best First'.
Re: Accessing FTP server using Net::FTP with any username and password
by vinoth.ree (Monsignor) on Apr 18, 2013 at 05:13 UTC
    login ([LOGIN [,PASSWORD , ACCOUNT ] ])

    Log into the remote FTP server with the given login information. If no arguments are given then the Net::FTP uses the Net::Netrc package to lookup the login information for the connected host. If no information is found then a login of anonymous is used. If no password is given and the login is anonymous then anonymous@ will be used for password.


    All is well
Re: Accessing FTP server using Net::FTP with any username and password
by derby (Abbot) on Apr 18, 2013 at 13:51 UTC

    It's been a while since I've dealt with Net::FTP but from what I recall, the login method does not raise an exception, you need to do that.

    eval { $ftp = Net::FTP->new( $in, Debug => 0 ); $ftp->login( $username, $password ) or die "Cannot login ", $ftp->message; }; if( ! ( $@ ) ) { print ... }
    -derby

      It worked!!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1029255]
Approved by vinoth.ree
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2022-06-29 09:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (96 votes). Check out past polls.

    Notices?