#!/usr/bin/perl # #NAME # kill - send signal to a CGI process # #SYNOPSIS # http://host.com.ain:port/CGI/kill?p=123&s=1 # #DESCRIPTION # This implements a kill command via a web browser. It does the kill with # the web server's permissions, so it can kill wild processes spawned by the # web server. # # This is intended as a web debugging and troubleshooting tool. It's not a # good idea to install this in a "live" web server's directories. But it's # very useful for fixing So you should link it into a cgi directory # temporarily, and remove it when you've fixed things up. # #OPTIONS # #FILES # #BUGS # Runs with the web server's permissions, so it can do anything to your web # site. Don't leave it visible to the outside world. # #SEE ALSO # #AUTHOR John Chambers $| = 1; use CGI; use CGI::Carp 'fatalsToBrowser'; use diagnostics; print "Content-type: text/html\n\n"; print "Test CGI $0\n"; print "
Test CGI $0
\n"; print "This is a test of a simple CGI script.\n"; print "
Here are our form elements:\n"; $query = new CGI; @names = $query->param(); print "
\n"; for $n (sort @names) { if (@vals = $query->param($n)) { for $v (@vals) {print "
$n
\"$v\"\n"} } elsif ($v = $query->param($n)) { print "
$n
\"$v\"\n"; } else { print "
$n
(NO VALUE)\n"; } } print "
\n"; print "
Here are our environment variables:\n"; print "
\n"; for $e (sort keys %ENV) { $v = $ENV{$e}; print "
$e
$v\n"; } print "
\n"; unless (defined($sig = $query->param('s'))) { # s= gives us a signal print "No signal supplied.
\n"; } unless (defined($pid = $query->param('p'))) { # p= gives us a process id print "No PID supplied.
\n"; } unless (defined($pat = $query->param('P'))) { # P= gives us a perl pattern print "No PAT supplied.
\n"; } unless (defined($cmd = $query->param('c'))) { # c= gives us a command (tricky to do right!) print "No cmd supplied.
\n"; } if (defined($sig) && defined($pid)) { print "
\n"; print "kill -$sig $pid
\n"; system "kill -$sig $pid"; print "Result status was $?\
n"; } if (defined($sig) && defined($pid)) { print "
\n"; print "Kill -$sig $pid
\n"; system "Kill -$sig $pid"; print "Result status was $?\
n"; } if (defined($cmd)) { print "
\n"; print "$cmd
\n"; system $cmd; print "Result status was $?
\n"; } print "
\n";