http://www.perlmonks.org?node_id=996275


in reply to Re^2: Unix 2 Perl Module FTP
in thread Unix 2 Perl Module FTP

First, I'm not sure why you're escaping a forward slash. Secondly, I expect that line's not where the problem is -- I imagine the problem is lower down, where you're trying to log in to the ftp site.

What error do you see when you run this script? Could not log in .. perhaps? Does the same login work when you try this interactively?

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Replies are listed 'Best First'.
Re^4: Unix 2 Perl Module FTP
by simbalion (Initiate) on Sep 28, 2012 at 19:00 UTC
    If I login interactively from the CLI on host, I do the following: FTP OPEN ip port USER DOMAIN\user1 DOMAIN/user1 or user1@FQDN all work pass password321 I get in successfully

      OK. Now we're getting somewhere. I'm guessing you want

      $ftp_user = 'DOMAIN\\user1';
      as your username definition.

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re^4: Unix 2 Perl Module FTP
by simbalion (Initiate) on Sep 28, 2012 at 21:06 UTC
    I have simplified the module to this: #!/usr/bin/perl use Net::FTP; $ftp = Net::FTP->new("9.9.9.9 5000", Debug => 0) or die "Cannot connect to some.host.name: $@"; $ftp->login("Domain\\user1",'password321') or die "Cannot login ", $ftp->message; $ftp->quit; for the domain I have tried: Domain\user Domain\\user Domain\/user Domain/user Nothing will work guys. Error received: Cannot login Invalid userid/password

      You said that user1@FQDN worked from the FTP client but you didn't say that you've tried it from your Net::FTP script. Also, double check that you have the right password in your script.

      #!/usr/bin/perl use strict; use warnings; use Net::FTP; my $ftp_site = '9.9.9.9 5000'; my $ftp_dir = '/Directory2'; my $ftp_get_file = 'that.file'; my $ftp_user = 'user1@FQDN'; # if 'DOMAIN/user1' and 'DOMAIN\\user +1' don't work, perhaps this will my $ftp_password = 'password321'; # double check your password, maybe +it's the problem! my $ftp = Net::FTP->new($ftp_site) or die "Could not connect to $ftp_site: $@"; $ftp->login($ftp_user, $ftp_password) or die "Could not login to $ftp_site with user $ftp_user: ", $ftp-> +message; $ftp->cwd($ftp_dir) or die "Could not change remote working directory to $ftp_dir on $f +tp_site: ", $ftp->message; $ftp->get($ftp_get_file) or die "Could not get $ftp_get_file the file is not present in $ftp +_dir: ", $ftp->message; $ftp->quit();
Re^4: Unix 2 Perl Module FTP
by simbalion (Initiate) on Oct 01, 2012 at 19:00 UTC
    Muskrat, the whole topic is about not being able to execute the script, I pasted the script in this post????? I have the correct user/pass I tested from unix ftp to windows fine, the same user/pass loaded into the variables will not work in the script.

      If a sign-in that works from the prompt doesn't work from your script, then I don't know what to suggest.

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re^4: Unix 2 Perl Module FTP
by simbalion (Initiate) on Sep 28, 2012 at 18:56 UTC
    I have tried the following: $ftp_user = "DOMAIN\user" and also the following: "DOMAIN/user" "\\DOMAIN\user" 'DOMAIN\/user' 'DOMAIN/\user' all of them: I have tried declaring a variable $ftp_domain = 'DOMAIN'; and including it on the login section of the f +tp module e.g. $ftp->login($ftp_user, $ftp_password) added these as well ($ftp_domain, $ftp_user, $ftp_password) still inv +alid user/pass I have alos hard coded the parameters in the above login statement ins +tead of using variables.

      I think one of us is missing the point.

      I don't think *setting* ftp_user's initial value is the problem -- I think you're running into a problem when you try to do an ftp login *using* the $ftp_user variable.

      Please tell me what error are you seeing. And replying with "It doesn't work" is the *wrong* answer.

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

A reply falls below the community's threshold of quality. You may see it by logging in.