synchronus ftp call

Discussion in 'Perl Misc' started by chris, Nov 6, 2004.

  1. chris

    chris Guest

    I have the following bit of code that makes a call to the ftp binary.
    The call seems to be happening asynchronusly. How can I make perl
    wait for the print FTP statement to finish?

    Is there a better way of doing this (e.g. system() call, etc.,)? My
    perl version is 5.005_02 built for PA-RISC1.1. I am not able to use
    any perl libs such as Net::Ftp.

    #################################

    open FTP, "|$FTP -n" or die $!;

    print FTP <<EndFTP
    open $FTP_SITE
    user $FTP_USER
    pass $FTP_PASS
    get README
    quit
    EndFTP

    #################################

    Thanks in advance,

    Chris
     
    chris, Nov 6, 2004
    #1
    1. Advertisements

  2. chris wrote:

    > Subject: synchronus ftp call


    > I am not able to use any perl libs such as Net::Ftp.


    You are not partitioning your question correctly. You've concuded that
    you are not able to use Net::FTP but need to use a subprocess. As such
    the Perl part of your question is only about handling subprocesses an
    not about FTP.

    > I have the following bit of code that makes a call to the ftp binary.
    > The call seems to be happening asynchronusly.


    > open FTP, "|$FTP -n" or die $!;
    >
    > print FTP <<EndFTP
    > open $FTP_SITE
    > user $FTP_USER
    > pass $FTP_PASS
    > get README
    > quit
    > EndFTP


    When you issue a close(FTP) perl will wait for the subrocess to complete.

    > How can I make perl wait for the print FTP statement to finish?


    It is not the print statement you want to wait for, it is the subrocess.

    > Is there a better way of doing this (e.g. system() call, etc.,)?


    You can put the ftp session input into a temporary file then use
    system(). This, of course, has little to do with Perl - it would apply
    equally in most languages.
     
    Brian McCauley, Nov 6, 2004
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. someone

    FTP over SSL vs FTP over SSH

    someone, Apr 24, 2004, in forum: Java
    Replies:
    1
    Views:
    4,871
    iksrazal
    Apr 25, 2004
  2. Replies:
    3
    Views:
    6,552
  3. Nico Grubert
    Replies:
    0
    Views:
    874
    Nico Grubert
    Nov 24, 2005
  4. jakecjacobson

    FTP example going through a FTP Proxy

    jakecjacobson, Jan 7, 2009, in forum: Python
    Replies:
    3
    Views:
    2,352
    jakecjacobson
    Jan 8, 2009
  5. Vin Raja

    FTP : Time problem (net/ftp)

    Vin Raja, Jun 7, 2007, in forum: Ruby
    Replies:
    0
    Views:
    235
    Vin Raja
    Jun 7, 2007
  6. Ari Brown

    Net::FTP and ftp.dir()

    Ari Brown, Jul 16, 2007, in forum: Ruby
    Replies:
    0
    Views:
    199
    Ari Brown
    Jul 16, 2007
  7. Jeff Miller
    Replies:
    0
    Views:
    895
    Jeff Miller
    Mar 26, 2009
  8. D. Buck
    Replies:
    2
    Views:
    959
    D. Buck
    Jun 29, 2004
Loading...