in reply to Re^6: Executing command from perl script with input/output
in thread Executing command from perl script with input/output

Oops, I meant to change the $cmd to "$cmd\n", but I hoped you would figure that out. Remember, the bash shell needs a newline (or enter) to start executing the command. Maybe even use 2 print statements, one to print $cmd, and one to print the code for enter(a newline). Additionally you may need to set $|=1; and maybe even try using syswrite instead of print. If none of those things work, you can try to setup a pseudo-tty, which I find quite difficult. See IO::Pty.

If all fails you can always fall back to using the old standby "expect" instead of IPC::Open3.

Quite often, it is some little tiny error you are making which prevents you from getting output, even if you have it setup right, and it usually involves buffering and flushing, so the $|=1 is important. If buffering is the problem, you might see the output as you quit the program.


I'm not really a human, but I play one on earth. flash japh
  • Comment on Re^7: Executing command from perl script with input/output

Replies are listed 'Best First'.
Re^8: Executing command from perl script with input/output
by linuxfan (Beadle) on Aug 12, 2005 at 21:15 UTC
    Zentara,

    As expected, I printed the "\n" along with $cmd. However, none of the methods you suggested has worked for me :( I guess I will try installing the Expect module and figure out a way to do this.

    Thanks a lot for your help!