I'm trying to run another program from my script that takes a number of command-line args. Normally, the child program will execute successfully---using readpipe or a variation on open to execute it---when given the proper arg list and it sets a return code which I can examine via $?. So far, so good. The problem arises in the case of the program's "delete" argument, which displays an "Are you sure? (y/n)" back to STDOUT and requires a confirming "y" to actually execute it.
Here's a snippet from my script with a version which uses tmpfiles to grab the STDOUT and STDERR:
...
my $cmd = $icstool . " " . $cmdargs . "1>$outfile" . " 2>$errfile";my $status = scalar 0; readpipe $cmd; $status = $? ; open(OUT,"<$outfile") or die "Couldn't open stdout file for reading: $!\n"; @outlines = <OUT>; close(OUT); open(ERR,"<$errfile") or die "Couldn't open stderror file for reading: $!\n"; my @errlines = <ERR>; close(ERR); print "$status|@outlines|@errlines"; exit $status;
While I've tried a number of different tactics instead of this simple readpipe (backtics, open3, bi-directional pipes, etc.) to capture and respond to the child's question during execution, I simply haven't yet found the sequence of magical incantations to 1) know that the child has displayed a msg (I'd like to be able to grab it and parse it, before I answer it), and 2) be able to shove a "y" or "n" back into the child's STDIN. Any pointers or thoughts would be much appreciated.
Thanks.
--ted
********************************************************
Ted Markowitz
_
Chief Architect, C O G N O S Y S L L C
10 Hamilton Lane, Darien, CT 06820-2809
203.984.6565 (phone) mailto:[EMAIL PROTECTED]
203.655.7746 (fax) http://www.cognosys.net
aim:GoIM?ScreenName=TJMarkowitz
********************************************************
begin:vcard n:Markowitz;Ted tel;cell:203-984-6565 tel;fax:203-655-7746 tel;work:203-655-7746 x-mozilla-html:TRUE url:http://www.cognosys.net org:Cognosys LLC version:2.1 email;internet:[EMAIL PROTECTED] title:Chief Architect adr;quoted-printable:;;10 Hamilton Lane=0D=0A;Darien;CT;06820;USA fn:Ted Markowitz end:vcard