Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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 perusing the Monastery: (5)
As of 2018-03-18 00:57 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (228 votes). Check out past polls.