Fellow monks,
I have this piece of code that respawns CruiseControl.net on our project build server :
#!/usr/bin/perl -w
use strict;
use warnings;
use Win32;
my (@ccnet, $ccpid, $cwd);
# --- Grep ccnet.exe pid
@ccnet = split(/\n/,`C:\\systools\\\@SI\\PsTools\\pslist.exe`);
@ccnet = grep(/ccnet/, @ccnet);
$#ccnet and print "@ccnet\n";
($ccpid) = "@ccnet" =~ /ccnet\s+(\d+)\s+/;
# --- Kill ccnet.exe, if it exists
if ( ! $ccpid ) { warn "NO ccnet\n"; }
else { print "found ccnet (pid:$ccpid)\n";
kill('HUP', $ccpid);
print "killed ccnet.exe (pid:$ccpid)\n";
sleep(3);
}
# --- Respawn ccnet.exe
print "respawning ccnet.exe\n";
$ENV{SSDIR} = '\\Blr11e\kmd.sdpi.ews1';
$cwd = Win32::SetCwd("C:\\Program Files\\CruiseControl.NET\\server"
+)
|| die "$!";
exec("start ccnet.exe") or print "couldn't exec ccnet: $!";
The code does as expected when run from a cmd-window on Windows (starts a new window and execs ccnet.exe in this window).
However...
When I execute this code from my perl cgi.script :
# Run ResetCCN.pl (exec overlay, - don't wait for new ccnet!)
sub respawn_CCNet {
print "<hr><h4>Restarting CCNet, -- please WAIT</h4><pre>";
system("perl ResetCCN.pl"); sleep(10);
print "</pre><br>DONE!<hr>";
}
it respawns the ccnet process in the
background (it's alive and visible in the process list), BUT it is not running (as i want it to) in a cmd window...
I've browsed the several Win32 modules for process control on Windows, but can't seem to find any suitable way to accomplish what I want.
Any pointers here...??
Best regards,
Allan Dystrup
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.