Want to execute a perl script within a perl script
I need a help on perl. I am new to it. I want to execute a perl script from my parent perl script and cover the following scenarios:
if (my child script takes more time than my time limit)
{
I need to kill the child script with a return code
logged into my parent script log file
}
if (my child script failed to execute)
{
I need to write a new RC to my parent script logfile 开发者_开发技巧
by looking at my child script exit status
}
Can any body provide code for this like how to use fork, exec and process related commands to fetch process id of children when my parent script gets executed?
The perlipc (inter-process communication) man page would be a good place to start.
Generally:
fork() returns an in integer, undef if it fails.
You check the value of the integer
- if it is 0 then you're in the child, and you run your childish tasks.
- if it is not 0 then your in the parent, and you have the pid of the child, so you wait for it, or reap it as needed.
There's a good example of the skeleton of this kind of code in the perlipc document that davorg already mentioned.
精彩评论