Restart piktc_svc

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
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2019-01-12.   This site is PIKT® powered.
Copyright © 1998-2019 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
clear tmp
directories
Pikt script