Note: I am a Perl newbie with about 10 days of experience in the language. Translation: "I'm dumb. Don't make me cry too much."
I'm presently writing a command line interface for a script. I want to be able to start and stop a second process from the first. I have been unable to figure out a solution that works for my specific situation. Here's what I've tried so far:
Option#1:
system("start ANYFILE.pl");
This allows me to fire off the second Perl script in the background, but I am unable to figure out a way to maintain some kind of reference to the process through which I can kill it.
Option #2:
$PID = fork();
This would allow me to keep a handle on the process if I were able to figure out how to use it to fire off the second Perl script.
Option #3:
Win32::Process::Create( my $ProcessObj,
"c:\\dir1\\dir2\\ANYFILE.pl", 0,
0, NORMAL_PRIORITY_CLASS, ".")
|| die "Create process $!";
This would be a great solution, since it allows me to keep a handle on the process. The problem is I am unable to figure out how to launch a Perl script using it. Apparently, even though I have my extensions correct I cannot "execute" a Perl script.
I would appreciate help getting any of these solutions to work, a solution other than these which would solve my problem, and even explainations as to why one or more of these solutions wouldn't work. It's always a plus to learn what you did wrong and why it's wrong!
-Mikeo
BTW, the script is being developed on a Windows box for use on Windows boxes.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.