Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Unix 2 Perl Module FTP

by simbalion (Initiate)
on Sep 28, 2012 at 18:27 UTC ( [id://996264]=perlquestion: print w/replies, xml ) Need Help??

simbalion has asked for the wisdom of the Perl Monks concerning the following question:

if [[ -a file*.ach || -a file2 ]] #check if files exist then set +x #turn on debug echo "********************************************************* +**" echo "** The file*.ach and/or file2 file already exists. **" echo "***********************************************************" exit 99 #if the any one of two files exist exit program else set +x echo "*************************************" echo "** No files exist, continueing on. **" echo "*************************************" set -x fi #no files then run the ftp job. ftp -vin << EOD open 9.9.9.9 #ip of ftp server user DOMAIN\/user1 password321 # DOMAIN\user then password Microsoft domain login case prompt cd directory1\/directory2 mget file*.ach quit EOD

## Can someone help me convert this to a Net::FTP module. I am good and my modules will work, except for passing the DOMAIN/user1 parameter. I connected to the CLI and did an FTP > OPEN and typed in username DOMAIN\user1 as well as DOMAIN/user1 and user@domain.com they all worked and connected through FTP from the prompt. But in my Perl Module if I declare and initialize my variables with $ftp_user = "DOMAIN\/user" it will not work (tried all kinds of ways, seems as though it only likes to take in single string characters) and always gives me a bad login message. error 530

if I run my perl module with just a regular username and or connect to say ftp.oreilly.com no issues, its when I try to prefix the username with an internal domain name, the FTP server is in house so the domain name must prefix the username.

Replies are listed 'Best First'.
Re: Unix 2 Perl Module FTP
by talexb (Chancellor) on Sep 28, 2012 at 18:38 UTC

    Great -- now show us how you've tried to use Net::FTP to achieve the same thing, and what problems you're running into.

    Alex / talexb / Toronto

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

      $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();
          $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

        A reply falls below the community's threshold of quality. You may see it by logging in.
        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.
        I get an error 530 invalid user/pass

        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
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://996264]
Approved by davido
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found