- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: I need a perl script to stop and start program
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 08:49 AM
тАО07-21-2005 08:49 AM
Re: I need a perl script to stop and start program
I mean to do this as a root user ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 10:29 AM
тАО07-21-2005 10:29 AM
Re: I need a perl script to stop and start program
exec 1>>/var/tmp/nlog.txt
exec 2>&1 to the top of your ntop.sh
You then put plenty of echo in the script and everything inclding stderr will now go to /var/tmp/nlog.txt and you look there for the problems. This is debugging 101.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 11:07 AM
тАО07-21-2005 11:07 AM
Re: I need a perl script to stop and start program
-----------------------------------------------------------------------------------------------------
#!/bin/sh
interfaces=''
# User to run ntop as; leave blank for root
userid='www'
# [IP:]port for serving HTTP; set to '0' to disable
#http_port='3000'
# [IP:]port for serving HTTPS; set to '0' to disable
# The certificate is /usr/local/etc/ntop/ntop-cert.pem
https_port='10.10.3.77:3001'
# Directory for ntop.access.log
logdir='/var/log'
# Specify any additional arguments here - see ntop(8)
additional_args=''
#
# End of user-configurable variables
#
args='-d -L --set-pcap-nonblocking --skip-version-check'
[ ! -z $interfaces ] && args="$args -i $interfaces"
[ ! -z $http_port ] && args="$args -w $http_port"
[ ! -z $https_port ] && args="$args -W $https_port"
[ ! -z $logdir ] && args="$args -a ${logdir}/ntop.access.log"
[ ! -z $userid ] && args="$args -u $userid"
[ ! -z "$additional_args" ] && args="$args $additional_args"
case "$1" in
start)
# is it the first time we run ntop
[ ! -e /var/db/ntop/ntop_pw.db ] && {
# just in case...
[ ! -d /var/db/ntop ] && {
echo "Reinstalling database directory"
mkdir -p /var/db/ntop
chown -R $userid:$userid /var/db/ntop
}
/usr/local/bin/ntop -u $userid -A || exit 1
echo "Now we can start ntop!"
}
if [ -d $logdir ]; then
touch ${logdir}/ntop.access.log
chown $userid ${logdir}/ntop.access.log
fi
if [ -x /usr/local/bin/ntop ]; then
/usr/local/bin/ntop $args > /dev/null 2>&1 &
echo -n ' ntop'
fi
;;
stop)
killall ntop > /dev/null 2>&1 && echo -n ' ntop'
;;
*)
echo "Usage: `basename $0` {start|stop}" >&2
exit 64
;;
esac
exec 1>>/var/tmp/nlog.txt
exec 2>&1 to the top of your ntop.sh
exit 0
-----------------------------------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 11:53 AM
тАО07-21-2005 11:53 AM
Re: I need a perl script to stop and start program
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-12-2007 10:19 PM
тАО06-12-2007 10:19 PM
Re: I need a perl script to stop and start program
#!/usr/bin/perl -w
# ntop startup script
use strict;
use warnings;
use CGI;
#use CGI::Carp qw(fatalsToBrowser);
my $query = new CGI;
my $process = "ntop";
# write the log
BEGIN
{
use CGI::Carp qw(carpout);
my $errorlog = "/var/tmp/ntop_startup_log.txt";
open(LOG, ">$errorlog") or die("Unable to open $errorlog: $!\n");
print LOG "Errors:\n";
carpout(*LOG);
}
$|=1;
print $query->header;
print "\n";
print "\n";
print "
print "\n";
print "<SCRIPT LANGUAGE = \"JavaScript\">\n";
print "\n";
print "</SCRIPT>\n";
print "\n";
print "
print "
\n";
print "
my $return = 'ps -eaf |grep $process |grep -v grep';
my $stop = '/usr/local/bin/sudo /usr/local/www/apache22/cgi-bin/ntop/ntop stop' ;
#if ($return ne "" ) {
#system($stop) == 0 and die "Stop failed: $!"
#}
sleep(10);
print "status:\n";
my $start = system('/usr/local/bin/sudo /usr/local/www/apache22/cgi-bin/ntop/ntop start') and die "...";
print "
";
print "
pls do not forget to shutdown ( kill ), if you're not using \n";
print "\n";
print "
print "pls wait for 10 seconds before you click on this link:\n";
print "
";
print "GO TO NTOP\n";
print "
";
print "KILL NTOP\n";
print "
print "";
print "";
and here is the killing script:
#!/usr/bin/perl -w
# ntop kill script
use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $query = new CGI;
my $process = "ntop";
# write the log
BEGIN
{
use CGI::Carp qw(carpout);
my $errorlog = "/var/tmp/ntop_kill_log.txt";
open(LOG, ">$errorlog") or die("Unable to open $errorlog: $!\n");
print LOG "Errors:\n";
carpout(*LOG);
}
$|=1;
print $query->header;
print "\n";
print "\n";
print "
print "\n";
print "<SCRIPT LANGUAGE = \"JavaScript\">\n";
print "\n";
print "</SCRIPT>\n";
print "\n";
print "
print "
\n";
print "
print "
my $return = 'ps -eaf | grep $process |grep -v grep';
my $stop = '/usr/local/bin/sudo /usr/local/www/apache22/cgi-bin/ntop/ntop stop' ;
#if ($return ne "" ) {
# system ($stop) and die "...";
#}
#if ($return ne "" ) {
#system($stop) == 0 or die "...: $!"
#}
sleep(3);
if ($stop == -1) {
print "failed to execute: $!\n";
} elsif ($stop & 127) {
printf "died with signal %d, %s coredump\n",
($stop & 127), ($stop & 128) ? 'with' : 'without';
} else {
printf " exited with value %d\n", $stop >> 8;
}
print "\n";
print "
";
print "START NTOP\n";
print "
";
print "
print "";
print "";
maka a great day !
chris
- « Previous
-
- 1
- 2
- Next »