Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Think about Loose Coupling
 
PerlMonks  

Re^2: Unix 2 Perl Module FTP

by simbalion (Initiate)
on Sep 28, 2012 at 18:43 UTC ( #996271=note: print w/ replies, xml ) Need Help??


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

$ftp_site = '9.9.9.9 5000'; $ftp_dir = '/Directory2'; $ftp_user ='DOMAIN\/user1'; ###here is the problem line $ftp_password = "password321"; 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->cwd($ftp_dir) or die "Could not change remote working " . "directory to $ftp_dir on $ftp_site"; $ftp->get($ftp_get_file) or die "Could not get $ftp_get_file" . "the file is not present in $ftp_dir"; $ftp->quit();


Comment on Re^2: Unix 2 Perl Module FTP
Download Code
Re^3: Unix 2 Perl Module FTP
by simbalion (Initiate) on Sep 28, 2012 at 18:48 UTC
    I get an error 530 invalid user/pass
Re^3: Unix 2 Perl Module FTP
by talexb (Canon) on Sep 28, 2012 at 18:49 UTC
      $ftp_user ='DOMAIN\/user1';  ###here is the problem line

    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

      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

      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

      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();
      So did everyone give up on this one , where are the MONKs!
      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^3: Unix 2 Perl Module FTP
by runrig (Abbot) on Sep 28, 2012 at 19:02 UTC
    Read (at least) the SYNOPSIS of the Net::FTP docs. Change the first $! to $@. Include $ftp->message() in all of the other diagnosic error messages.
      When using your example of $ftp_user = 'DOMAIN\\user1'; I get the error: Could not login to 9.9.9.9 1000 with user DOMAIN\user1: at ./test.pl +line 34. ##1000 is the port sed -n 34p test.pl showed me : $ftp->login($ftp_user, $ftp_password) #line 34
      Sir I read the SYNOPSIS and line 6 is still where there is no clarific +ation: If you had a MS Domain controller where the logins were DOMAIN\user password how would you "hard code" that in line 6 of the SYNOPSIS example $ftp->login("anonymous",'-anonymous@') How would you format this pluggin in the correct syntax I swear I have + tried it all!!!
Re^3: Unix 2 Perl Module FTP
by Generoso (Priest) on Sep 30, 2012 at 03:06 UTC

    Going form UNIX to Windows The file naming is different i.e /Domain/user/ftp in UNIX will be something like "C:\\Domain\\user\\ftp" for Windows.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2014-04-19 03:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (477 votes), past polls