Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

system call to ftp

by Anonymous Monk
on Mar 24, 2012 at 05:01 UTC ( #961356=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I have tried to login ftp using system call, like
#!usr/bin/perl $host = ""; system("ftp -n $host"); system("pass root xxxxxx"); system("quit");
i want to capture the output to a variable, and i dont want to use Net::FTP or any packages, Here i am not getting logged in ftp , can you point me out in right direction or any code changes?

Replies are listed 'Best First'.
Re: system call to ftp
by GrandFather (Sage) on Mar 24, 2012 at 05:46 UTC

    That just ain't gonna fly! system is somewhat like logging on, executing a command line, then logging off again (under the hood it forks then execs the command and waits for the forked process to terminate). You would most likely be much better off using a module such as the Net::FTP module you mention to get the job done.

    True laziness is hard work
      Okay, Agreed .But the other system which the script going to be put into run,may or may not have Net::FTP (old perl version) or its dependent packages which in turn gives problem , ie why i tried to use system, Anyhow i have partially fixed the problem ,
      .... system("ftp -n -s:ftpcred.txt $host > out.txt"); .... # file:ftpcred.txt #================== user root xxxx ls quit
        FYI, Net::FTP is a core dual-lived module. If the other system has perl installed, then it has Net::FTP.
Re: system call to ftp
by JavaFan (Canon) on Mar 24, 2012 at 08:41 UTC
    That's not how system works. There's a parallel, persistent, universe going on in which you can make calls back and forth. You're first system starts another process, and executes ftp -n in that. Your second system create another process, and attempts to execute the command pass root xxxxxx, and the third create yet another program, to execute quit.

    i dont want to use Net::FTP or any packages
    In that case, open a socket to the FTP port, and implement the FTP protocol yourself.

    I'm not going to help you with that. Asking for help but not willing to use packages is like asking for help to write a resume -- but one that doesn't use the letters 'e', 'a' or 'o'.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://961356]
Approved by GrandFather
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2017-06-28 19:22 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (643 votes). Check out past polls.