Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running multiple scripts within perl script

Status
Not open for further replies.

prekursor

Technical User
Apr 20, 2007
4
US
Here is my question:
I would like to start three different perl scripts from one script without waiting for exit status of a previous one.
(I want script: script1.pl script2.pl and script3.pl run the whole day)
how do I accomplish that?
This is what i had in mind:

print "starting first script";
system(script1.pl);
print "starting second script";
system(script1.pl);
print "starting third script";
system(script3.pl);
 
Use fork() or threads (Perl 5.8)

Code:
use threads;

my $t1 = threads->create (sub {
   system ("start script1.pl");
});
my $t2 = threads->create (sub {
   system ("start script2.pl");
});
my $t3 = threads->create (sub {
   system ("start script3.pl");
});

# rejoin the threads when they exit
$t1->join;
$t2->join;
$t3->join;

# all threads have finished, exit main thread
exit(0);


-------------
Cuvou.com | The NEW Kirsle.net
 
OK i found out.
I need to use & for all of them
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top