fooling a process' requests for input 
Author Message
 fooling a process' requests for input

Greetings,
I have a shell script that wraps around a hoary old executable that was
written to accept input from a human being -- it asks questions and gets the
answers from fingers on a keyboard.

The wrapper script has a file full of important data and fools the old
executable like so:

while read TICKNUM
do

 printf "Changing [%s]..." $TICKNUM

 /sys01/ar/scripts/oldscript.sh << EOT > /dev/null 2>&1
`hostname`
helpdesk
$TICKNUM
1
EOT
done < DATAFILE

So I know to use system with perl to process the oldscript.sh but how do I
simulate the newlines between "answers" to oldscript.sh's questions?

So in perl the script starts to look like this:

open(INFO, $INFILE);
while ($TICKNUM = <INFO>);
{
        print "Changing $TICKNUM...";

        system $BINDIR/cleanRemSch.sh << EOT
`hostname`
helpdesk
$TICKNUM
1
EOT

Quote:
}

except for the parts between the first EOT and the end EOT.

Any guidance would be appreciated.
randy




Wed, 18 Jun 1902 08:00:00 GMT  
 fooling a process' requests for input

    > Greetings, I have a shell script that wraps around a hoary old
    > executable that was written to accept input from a human being
    > -- it asks questions and gets the answers from fingers on a
    > keyboard.

    > The wrapper script has a file full of important data and fools
    > the old executable like so:

    > while read TICKNUM do

    >  printf "Changing [%s]..." $TICKNUM

    >  /sys01/ar/scripts/oldscript.sh << EOT > /dev/null 2>&1
    > `hostname` helpdesk $TICKNUM 1 EOT done < DATAFILE

    > So I know to use system with perl to process the oldscript.sh
    > but how do I simulate the newlines between "answers" to
    > oldscript.sh's questions?

    > So in perl the script starts to look like this:

    > open(INFO, $INFILE); while ($TICKNUM = <INFO>); { print
    > "Changing $TICKNUM...";

    >         system $BINDIR/cleanRemSch.sh << EOT `hostname` helpdesk
    > $TICKNUM 1 EOT }

    > except for the parts between the first EOT and the end EOT.

    > Any guidance would be appreciated.  randy


Randy;

You may want to look at the Expect.pm module.  Or, as Expect.pm does
not appear to be actively maintained, you may want consider the
original (expect under TCL).

Cheers.

--
Phil Eschallier        | Bux Technical Services | Systems, software,

  tel 215 348 9721     | Doylestown, PA  18901  | networking for your
  fax 215 230 8265     | http://www.BuxTech.Com | business!
KeyID D6E9B193



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. IPC::Open2 problem, process doesn't see input

2. IPC::Open2 problem, process doesn't see input

3. localtime and Win32: The april fool's bug

4. Request for advice - I'm preparing a module for CPAN and I don't wanna make a fool of myself.

5. SRC - Educational input on my search routine request.

6. Input for PERL Course request

7. Input for PERL Course request

8. Child processes don't clean up (defunct processes left) even though SIGCHLD does wait()

9. REQUEST: Need a sample 'curseperl' script

10. Processing HTTP image requests

11. 'MY HAIRIEST BUG' TALES: REPEATED REQUEST

12. IE user jamming the Stop button while Perl/IIS processing html post request

 

 
Powered by phpBB® Forum Software