Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

executing external program question

by echoangel911 (Sexton)
on Jun 19, 2007 at 15:08 UTC ( [id://622033]=perlquestion: print w/replies, xml ) Need Help??

echoangel911 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I need help/ideas on how to do this. I have this command in my perl script where I call this external program.
$tcl = 'load $gdsfile; $command1; $command2; etc ...'; $output = `abctool -shell $tcl`;
I found out that I need to generate some extra commands on the run while running the tcl code. Is there anyway I can execute the 'load $gdsfile' section and keep the program running? I do not want to rerun the whole command again since the 'load $gdsfile' code takes 1 hour to run. thanks

Replies are listed 'Best First'.
Re: executing external program question
by lin0 (Curate) on Jun 19, 2007 at 15:33 UTC
Re: executing external program question
by suaveant (Parson) on Jun 19, 2007 at 15:23 UTC
    You question isn't exactly clear, but maybe you want Expect.pm... it allows you to interact with a command line program like Tcl expect does

                    - Ant
                    - Some of my best work - (1 2 3)

Re: executing external program question
by odrm (Novice) on Jun 19, 2007 at 15:33 UTC
    Two rather different approaches spring to mind:
    1. Save the output from the long-running job to a temporary file, and read from that when you need the results
    2. Launch the long-running job as a sub-process of your Perl program, and use one of the many IPC (inter-process-communication) methods
    Alternative (a) is a lot easier to implement provided that you can run the 1hr+ job before the rest of the code. Data::Dumper or Storable are two useful modules if you want a "perlish" format to the results data. Alternative (b) may allow you to interact with the long-running job, but it is non-trivial to avoid all of the potential pit-falls of concurrent programming. You may want to investigate the IPC::Open2 module for this alternative.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://622033]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-25 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found