in reply to Taming multiple external processes
You can use ps to verify that before you tie the two programs together the pid that you got from open actually is the pid of the echo process that you launched.#! /usr/bin/perl use strict; use IPC::Open2; local *PIPE; local *OUT; my $pid = open(PIPE, "-|", "echo", "hi") or die "Can't echo: $!"; print "The pid of the echo command is: $pid"; <STDIN>; open2(\*OUT, "<&PIPE", "perl", "-ne", "print uc") or die "open2 failed: $!"; print while <OUT>;
UPDATE: I left out the assignment to pid. Added. (I had included an earlier version of the code, then commented about a later one that demonstrated the pid, then partially updated the code but missed one line. My apologies for any confusion.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Taming multiple external processes
by 87C751 (Acolyte) on Jan 02, 2004 at 09:36 UTC | |
by tilly (Archbishop) on Jan 02, 2004 at 15:56 UTC | |
by 87C751 (Acolyte) on Jan 02, 2004 at 20:25 UTC | |
|
Re: Re: Taming multiple external processes
by 87C751 (Acolyte) on Jan 02, 2004 at 08:47 UTC |