Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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 = "127.0.0.1"; 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?

Comment on system call to ftp
Download Code
Re: system call to ftp
by GrandFather (Cardinal) 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 127.0.0.1 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2014-10-24 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (131 votes), past polls