Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Executing one script with another

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


in reply to Executing one script with another

I think that you could either use system or exec to call the second program, passing it's parameters on the command line, or you could create a module from the second program, use it and move the outer-most level of logic in the second file into the first... I apologize if I'm missing what you're getting at.

Replies are listed 'Best First'.
Re: Executing one script with another
by MonkPaul (Friar) on Jul 14, 2005 at 17:07 UTC
    I looked at system and exec in my book, but it doesnt give a clear way to execute the second perl script.

    Could it be: system(BlastTool(#params here));
    (will look into that though, thanks).

    Also if i use system, as i understand it here, it creates a fork and waits for the son process to finish. Could i therefore implement a loading page also at this stage, and display a "waiting gif" or something whilst it waits for the son process to complete
    (- spiraling off with more and more ideas).

    Cheers, MonkPaul

      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://474956]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-24 22:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found