Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Executing one script with another

by socketdave (Curate)
on Jul 14, 2005 at 19:33 UTC ( [id://475024]=note: print w/replies, xml ) Need Help??


in reply to Re: Executing one script with another
in thread Executing one script with another

You're right about system() waiting for a child process to complete, but exec() works differently. It basically calls the program that you specify and kills the script that's currently running (unless the command can't run, in which case it will return false and put something interesting in $!). Generally I'd use exec() after forking, and use system() when you expect your external command to return in a timely fashion (In fact, system forks then execs and waits for the child to return before giving control back to the script). If you want to display an animated 'waiting' gif or something like it, system() would probably be the one you want.

In either case, you should enclose your command in quotes or generate an array with your command as the first element and it's arguments as the remaining elements:

system("/path/to/BlastTool my params here") or die "Could not run command";

or:
@command = ("command", "my", "params", "here"); system(@command) or die;

Log In?
Username:
Password:

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

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

    No recent polls found