CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
running a prog inside of a prog

 



Ghigman3
Deleted

Dec 17, 2000, 4:27 PM

Post #1 of 3 (242 views)
running a prog inside of a prog Can't Post

How do you run an external program from within another?



sleuth
Enthusiast / Moderator

Dec 17, 2000, 4:33 PM

Post #2 of 3 (240 views)
Re: running a prog inside of a prog [In reply to] Can't Post

 
Did you try include "script.pl"; ?

Sleuth



japhy
Enthusiast

Dec 17, 2000, 5:32 PM

Post #3 of 3 (239 views)
Re: running a prog inside of a prog [In reply to] Can't Post

There are basically three ways:


Code
# exec() replaces the current process with a new one 
exec $prog, @args;
# program only gets here if exec() failed
die "couldn't exec '$prog': $!";

# system() returns the exit status, NOT the output
system($prog, @args) and die "$prog failed: $?";

# backticks or qx!! return output
@output = `$prog @args` or die "$prog failed: $!";
$output = qx($prog @args) or die "$prog failed: $!";

You can use the open() function, but these will probably suffice. Please read perldoc -f exec and perldoc -f system for the documentation on those functions, and perldoc perlop for documentation on qx().

Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives