svcstart.pl is a simple Perl script to restart piktc_svc. This is the script version customized for Red Hat Linux as sourced from the svcstart_programs.cfg file.
#!/usr/bin/perl
# svcstart.pl -- kill/restart the piktc_svc daemon
die "Usage: svcstart.pl [-kr]\n" if $#ARGV != 0;
use Getopt::Std;
die "Usage: svcstart.pl [-kr]\n" if !getopts('kr');
$KILL = $opt_k;
$RESTART = $opt_r;
$pscmd = "/bin/ps axcl |
/usr/bin/awk '/pikt/ {printf(\"%s %s %s\\n\", \$3, \$4, \$NF)}'";
if ($KILL || $RESTART) {
# kill any running piktc_svc
open(PSCMD, "$pscmd |");
while (<PSCMD>) {
chop;
if (/^(\d+)\s+\d+\s+piktc_sv/) {
$pid = $1;
if (kill('SIGTERM', $pid)) {
printf "killed piktc_svc pid %d\n", $pid;
}
}
}
close(PSCMD);
}
if ($RESTART) {
# delete any piktc_svc.lock file
if (-e "/pikt/etc/piktc_svc.lock") {
system("/binb/rm /pikt/etc/piktc_svc.lock 2>/dev/null");
}
# restart piktc_svc
$cmd = "/pikt/bin/piktc_svc";
$cmd .= " &";
system($cmd);
# find new piktc_svc
open(PSCMD, "$pscmd |");
while (<PSCMD>) {
chop;
if (/^(\d+)\s+\d+\s+piktc_sv/) {
$pid = $1;
printf "new piktc_svc pid %d\n", $pid;
}
}
close(PSCMD);
}
[For more examples, see Samples.]
Home |
FAQ |
News |
Intro |
Samples |
Tutorial |
Reference |
Software |
Authors |
Licensing |
SiteSearch
Links |
SiteIndex |
Pikt-Users |
Pikt-Workers |
Contribute |
ContactUs |
Top of Page
Page best viewed at 1024x768.
Page last updated 2005-06-22.
This site is
PIKT®
powered.
PIKT® is a registered trademark of the University of Chicago.
Copyright © 1998-2005 Robert Osterlund. All rights reserved.
|