[grand-rapids-pm-announce] driving a process [using pipes?]

Al Tobey albert.tobey at priority-health.com
Tue Sep 27 15:10:39 PDT 2005


> Message: 2
> Date: Tue, 27 Sep 2005 08:41:44 -0500
> From: Cameron Walker <cameron.walker at fedex.com>
> Subject: [grand-rapids-pm-announce] driving a process [using pipes?]
> To: grand-rapids-pm-announce at pm.org
> Message-ID: <43394C18.8040606 at sac.fedex.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> I have a process (specifically the sybase 'ic' process) that I want to 
> send commands to and then recieve the output back for further processing.
> 
> I'm aware of how to send commands via
>     open(wp,"| ic")
>     print wp "sp_who"
>     print wp "go"
> etc and so on. On the other side I know how to read data in from a 
> process via
>     open(rp,"date |")
>     $input = <rp>

I think what you want is IPC::Open2 although I usually end up using
something heavier before too long like POE or IPC::Run.

use IPC::Open2;
my($read,$write); # will be auto-vivified Symbols
my $pid = open2( $read, $write, "ic" );

print $write "stuff\n";

my $result = <$read>;

There's also IPC::Open3 that provides STDERR along with STDIN and
STDOUT.

perldoc IPC::Open2
perldoc IPC::Open3
perldoc perlipc

perl -MCPAN -e install 'IPC::Run'
perldoc IPC::Run

-Al Tobey

> However, I cant figure out how to make these work together at the same 
> time. The 'ic' program apparently isnt smart enough for me to just feed 
> it the data on the command line so I _have_ to open an input pipe to the 
> thing in order to drive it. At this point my knowledge fails me. How do 
> I get the data back out?
> 
> I started to do a fork and quickly realized that that doesnt seem to 
> solve my problem. I've heard suggestions that I need to play with some 
> filehandles to deal with this but clearly Im to dense to comprehend what 
> I need to do.
> 
> If you have any ideas I would much appreciate a tip [ more like an 
> 'idiots guide' ].
> 
> Thanks.
> 
> 
> 
> 
> ------------------------------
> 
> _______________________________________________
> grand-rapids-pm-announce mailing list grand-rapids-pm-announce at pm.org
> http://mail.pm.org/mailman/listinfo/grand-rapids-pm-announce
> 
> End of grand-rapids-pm-announce Digest, Vol 13, Issue 3
> *******************************************************
> 
> _______________________________________________
> grand-rapids-pm-announce mailing list
> grand-rapids-pm-announce at pm.org
> http://mail.pm.org/mailman/listinfo/grand-rapids-pm-announce
> 

** ** **  PRIVILEGED AND CONFIDENTIAL  ** ** **
This email transmission contains privileged and confidential information intended only for the use of the individual or entity named above.  Any unauthorized review, use, disclosure or distribution is prohibited and may be a violation of law.  If you are not the intended recipient or a person responsible for delivering this message to an intended recipient, please delete the email and immediately notify the sender via the email return address or mailto:postmaster at priority-health.com.  Thank you.

- end -



More information about the grand-rapids-pm-announce mailing list