Hi Monks,
I am using IPC::Open2 for controlling INPUT AND OUTPUT of a programme
(bash shell). But, I am facing a little bit trouble. When I am giving
a command (which I am taking from STDIN, processing it and giving to shell).
The command, which I am giving to SHELL, if it is correct I am getting
it's output, but if I am giving a wrong command I am getting error.
But, from then onwards I am not getting output of even correct command.
what could be wrong ?? Can anybody help me ....
Thanks ....
#! /usr/bin/perl -w
use strict;
use IPC::Open2;
use FileHandle;
do {
my $pid = open2( \*Reader, \*Writer, "bash" );
Writer->autoflush(); # default here, actually
Reader->autoflush();
STDIN->autoflush();
my $cmd = <STDIN>;
print Writer $cmd;
my $got = <Reader>;
print $got;
} while(1);
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.