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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Process Management

Status
Not open for further replies.

dsingh1

IS-IT--Management
Joined
Aug 10, 2006
Messages
2
Location
US
Hi,

I want to write a perl script which call another perl script and the first one quit. Means it should call perl script in another thread and instead of waiting for that to finish it should quit. For example:

script1.pl will call script2.pl smoehow and script1.pl must quit after that and all the things will be done by script2.pl

Please put me on right way.

Daljit Singh
 
Try using system function from script 1

Code:
my $SCRIPTPATH = "/m/home/myuser";
my $SCRIPT = "script2.pl";
system ("$SCRIPTPATH/$SCRIPT");
exit;

dmazzini
GSM System and Telecomm Consultant

 
>>my $SCRIPTPATH = "/m/home/myuser";
>>my $SCRIPT = "script2.pl";
>>system ("$SCRIPTPATH/$SCRIPT");
>>exit;

In this code exit statement will work only when the control will be returned from system command. Means when script2 will be done then the control will return to script1 and then it execute the exit but what I want is to call the script2 and then parallely quit script1. Technically script1 should not be the parent of script2.

Daljit Singh
 
you could write a perl daemon which picks up the information for a process and starts it as a child process of the daemon, rather than the calling script.

I think when a parent script exits, depending on your OS, all child PIDS are harvested as well

Just a thought

--Paul


Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Try exec...

Code:
my $SCRIPTPATH = "/m/home/myuser";
my $SCRIPT = "script2.pl";
exec ("$SCRIPTPATH/$SCRIPT");

exec runs the new process while killing the current one. system returns when the process finishes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top