|Don't ask to ask, just ask|
I want to run a script from another script, use the same version of perl, and reroute IO to a terminal-like textboxby ric00015 (Beadle)
|on Oct 01, 2013 at 14:41 UTC||Need Help??|
ric00015 has asked for the
wisdom of the Perl Monks concerning the following question:
I am somewhat familiar with various ways of calling a script from another one. I don't really need an overview of each, but I do have a few questions. Before that, though, I should tell you what my goal is.
I am working on a perl/tk program that: a) gathers information and puts it in a hash, and b) fires off other scripts that use the info hash, and some command line args. Each of these other scripts are available on the command line (using another command-line script) and need to stay that way. So I can't just put all that into a module and call it good.I do have the authority to alter the scripts, but, again, they must also be usable on the command line.
The current way of calling the other script is by using 'do', which means I can pass in the hash, and use the same version of perl (I think). But all the STDOUT (and STDERR too, I think) goes to the terminal.
Here's a simple example to demonstrate the output:
How can I redirect the STDOUT and STDIN (for interactive scripts that need input) to the text box using the 'do' method? Is that even possible?
If I can't use the 'do' method, what method can redirect the STDIN and STDOUT, as well as enable passing the hash in and using the same version of perl?
Update! I talked with the one who originally created the scripts, and he agreed that jethro's suggestion of using modules and script wrappers was a good one. So that is what I am going to do. This ensures that I am not using different perls, I can route the output from the module anywhere I want, and passing that hash in is now very easy. Solves most, if not all, of my problems. Thanks, everyone, for your suggestions. See you around.