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

Re: Catching output from process that's not newline terminated

Expand Messages
  • the_land_baron
    Even this doesn t print out the command prompt. What am I missing? use FileHandle; use IPC::Open2; $pid = open2( *READHANDLE, *WRITEHANDLE,
    Message 1 of 2 , Mar 31, 2005
    • 0 Attachment
      Even this doesn't print out the command prompt. What am I missing?

      use FileHandle;
      use IPC::Open2;
      $pid = open2(\*READHANDLE, \*WRITEHANDLE, 'GPIB-CommandShell.exe');
      while (1 == 1) {
      if (!eof(READHANDLE)) {
      $char = getc(READHANDLE);
      print $char;
      }
      }


      --- In perl-beginner@yahoogroups.com, "the_land_baron" <jerramy@n...>
      wrote:
      >
      > Hi all,
      >
      > I'm trying to write a script that manipulates a custom command
      shell
      > I built. I'm hoping I can get away with using IPC::Open2, as I
      need
      > to be able to send commands to the shell, and then read it's output.
      >
      > As a first baby step, I simply want to make the Perl script
      > transparent to the user, so that any commands he types are sent to
      > the shell, and any output of the shell is displayed on the console.
      >
      > The problem I'm having is the prompt line. It's not terminated by
      a
      > newline character, and I think this is causing problems for Perl,
      as
      > the previous line of output (the welcome string) prints fine, but
      the
      > prompt doesn't.
      >
      > Here's my code:
      >
      > ###
      > use FileHandle;
      > use IPC::Open2;
      > $pid = open2(\*READHANDLE, \*WRITEHANDLE, 'GPIB-CommandShell.exe');
      > while ($output = readline *READHANDLE) {
      > print $output;
      > if ($output eq 'COMMAND:')
      > { print WRITEHANDLE (<STDIN>); }
      > }
      > ###
      >
      > Any help would be appreciated.
      >
      > Thanks,
      > Jerramy
    Your message has been successfully submitted and would be delivered to recipients shortly.