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. Advertising

  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. Advertising

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,591
    iksrazal
    Apr 25, 2004
  2. Replies:
    3
    Views:
    5,656
  3. Nico Grubert
    Replies:
    0
    Views:
    645
    Nico Grubert
    Nov 24, 2005
  4. Nico Grubert
    Replies:
    0
    Views:
    449
    Nico Grubert
    Nov 25, 2005
  5. D. Buck
    Replies:
    2
    Views:
    493
    D. Buck
    Jun 29, 2004
Loading...

Share This Page