hi
I need a perl script to stop & start program:
# stop PROGRAM
sh /home/ntop.sh stop
# start PROGRAM
sh /home/ntop.sh start
I'd like first stop the program and start it again using apache & browser.
kind regards
cc
Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
I need a perl script to stop & start program
Use the "system" function. You need to check the return value this way (this is a copy-paste from the 'perlfunc' manual page, which is your friend):
However, you can register shell scripts as cgi scripts, so you can write your program in shell script as well...
Code: Select all
system("sh /home/ntop.sh stop")
if ($? == -1) {
print "failed to execute: $!\n";
} elsif ($? & 127) {
printf "child died with signal %d, %s coredump\n",
($? & 127), ($? & 128) ? 'with' : 'without';
} else {
printf "child exited with value %d\n", $? >> 8;
}
thanks
I've written this script:
from command line it works well, but via browser I get:
Status: 0 ntop
in error log from apache I have:
[Thu Jul 21 22:50:54 2005] [error] [client 192.168.0.105] Permission denied
howto change rights to execute system "program" via browser ?
I've written this script:
Code: Select all
#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use CGI;
my $query = new CGI;
print $query->header;
print "<html>\n";
print "<head>\n";
print "<title>ntop startup script</title>\n";
print "</head>\n";
print "<body bgcolor='#c0c0d0'>\n";
print "<center>";
print "<p><br></p>";
print "<p><br></p>";
system `sh /usr/local/www/cgi-bin/ntop/ntop.sh stop`;
sleep(8);
my $start = system `sh /usr/local/www/cgi-bin/ntop/ntop.sh start &` or die "cannot start ntop: $!";
print "Status: ",$start,"\n";
print "</center>";
print "</body>";
print "</html>";
Status: 0 ntop
in error log from apache I have:
[Thu Jul 21 22:50:54 2005] [error] [client 192.168.0.105] Permission denied
howto change rights to execute system "program" via browser ?
Last edited by cc on 2005-07-27 01:02, edited 5 times in total.