Loading ...
Sorry, an error occurred while loading the content.

open2

Expand Messages
  • Mike D
    Folks, I m having some problems getting open2 to work and I was wondering if someone could help me out. Basically, I m spawning FTP in a process. I am writing
    Message 1 of 1 , Nov 30, 2001
    • 0 Attachment
      Folks,

      I'm having some problems getting open2 to work and I was wondering if someone
      could help me out.

      Basically, I'm spawning FTP in a process. I am writing a test script to test
      an FTP server that my company wrote. The FTP server has to resume aborted
      downloads. So the reason why I'm spawning the FTP application rather than
      using the Net::FTP module is because I have to kill the FTP transfer in the
      middle and I don't think that's possible with Net::FTP. So the reason why I
      need to use open2 is because I need to send and receive data to an external
      app, and regular open is not capable of that.

      So here's my code right now:
      use IPC::Open2 ;
      $ftpPid = open2( *FTPREAD, *FTPWRITE, '/usr/bin/ftp' ) ;

      # Here I'm trying to open the FTP session
      print FTPWRITE ( 'open 10.0.0.2' ) ;

      # Here I'm waiting for the command to be acknowledged so I can continue with
      more commands
      while( defined( $line = <FTPREAD> ) )
      {
      chomp( $line ) ;
      # This line wait for the Name regexp
      if( $line =~ m/Name/ )
      {
      last ;
      }
      }

      ...and so it hangs in these various while loops I have because there is
      apparently no data on the FTPREAD filehandle.

      Is there something else I need to or something? I have also tried opening
      the filehandles with \'s (i.e. \*FTPWRITE, \*FTPREAD ), but that doesn't seem
      to work either.

      Thanks,
      -MikeD

      __________________________________________________
      Do You Yahoo!?
      Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
      http://geocities.yahoo.com/ps/info1
    Your message has been successfully submitted and would be delivered to recipients shortly.