![]() |
|
Keep It Simple, Stupid | |
PerlMonks |
Running a shell script from Perl, and making that shell script accept input from perl script.by why_bird (Pilgrim) |
on Apr 08, 2008 at 07:38 UTC ( #678941=perlquestion: print w/replies, xml ) | Need Help?? |
why_bird has asked for the wisdom of the Perl Monks concerning the following question: Morning monks. This is a question about running a shell script from a Perl script, and then making the shell script wait and accept input from the perl script. I can only submit jobs to our queueing system via a shell script, but I want to do other stuff (involving e.g. Tie::File) that would be a real pain to re-write in a shell script. Recalling the shell script every time a job is generated and passing it the data from the Perl script is not an option, neither is waiting until all the jobs are generated and passing them en masse. It needs to start up, and then accept input as and when it's generated from the Perl script. The shell script basically does (pseudo code): The way I'm tackling this at the moment is to replace the foreach job loop with a loop like this:
The real crux of the question is this: How do I run the above shell script from a Perl script, then make it wait for input from STDIN whilst allowing the perl script to keep running? Currently, I've got something like this, which obviously doesn't work..:
Now, I understand why this doesn't work (the Perl script won't keep running if the shell script is started in the foreground, but the shell script won't accept input from STDIN if it's started in the background). But I don't know how to make it do what I want. My only thought was a fork---is this appropriate? Or can someone suggest a whole new approach to doing this? thanks, why_birdedit changed title to avoid confusion; readmore'd some text Those are my principles. If you don't like them I have others. -- Groucho Marx .......
Back to
Seekers of Perl Wisdom
|
|