in reply to (Expect) Re: question for open2, and by the way, resolves an old thread
in thread question for open2, and by the way, resolves an old thread

That was what I thought, but interestingly, I didn't get the prompt back through $reader, Hm.. where did it go?

If I can get it, the whole thing is resolved.

Update:

  1. tye's suggestion definitely makes sense, as it might be just the prompt is not flushed yet. But I tried this:
    #!/usr/bin/perl use IPC::Open2; use strict; my ($reader, $writer); my $pid = open2($reader, $writer, "sh") || die "failed"; print $writer "history\n"; my $buffer; sysread($reader, $buffer, 4000); print "[", $buffer, "]\n"; print $writer "ls\n"; sysread($reader, $buffer, 4000); print "[", $buffer, "]\n";
    There is no prompt being printed between two prints. So it means/proves that the prompt is NOT THERE, doesn't matter what it is, but I do like tye's suggestion, it is 100% logical.

  2. I did a research, and someone said on internet that sh does not output prompt if it is not used interactively. This matches my result.

    But is there a switch to toggle this feature?
  • Comment on Re: (Expect) Re: question for open2, and by the way, resolves an old thread
  • Download Code

Replies are listed 'Best First'.
Re^3: question for open2, and by the way, resolves an old thread ($/)
by tye (Sage) on Jan 17, 2003 at 20:43 UTC

    Set your prompt to include a newline if you want to read it with <$reader>.

                    - tye