- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- 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-20-2005 10:21 AM
тАО07-20-2005 10:21 AM
I need a perl script to stop and 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
chris
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-20-2005 11:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 05:52 AM
тАО07-21-2005 05:52 AM
Re: I need a perl script to stop and start program
I've written following perl script:
----------------------------------------------------------
#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use CGI;
my $query = new CGI;
$bb = system("/home/ntop.sh stop &");
exit($bb);
$cc = system("/home/ntop.sh start &");
exit($cc);
----------------------------------------------------------
if execute it from command line:
# perl ntop.cgi
then ntop starts,
but via browser, script be executed without errors, but ntop won't start.
# chown www ntop.cgi
doesn't help !
kind regards
chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 06:24 AM
тАО07-21-2005 06:24 AM
Re: I need a perl script to stop and start program
use CGI::Carp qw(fatalsToBrowser);
use CGI;
my $query = new CGI;
$bb = system("/home/ntop.sh stop &");
exit($bb); #### This exit terminate the program!!! Nothing past this point is done
$cc = system("/home/ntop.sh start &");
exit($cc);
-----------------------------------------
You made thimgs complicated using the & to stop in background.
Change to this:
#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use CGI;
my $query = new CGI;
my $bb = system("/home/ntop.sh stop");
sleep(10);
$cc = system("/home/ntop.sh start &");
exit($cc);
or this:
#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use CGI;
my $query = new CGI;
my $bb = system("/home/ntop.sh stop &");
wait; # wait for background task to finish
$cc = system("/home/ntop.sh start &");
exit($cc);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 07:04 AM
тАО07-21-2005 07:04 AM
Re: I need a perl script to stop and start program
---------------------------------------------------------------------------------------
#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use CGI;
my $query = new CGI;
print $query->header;
print "\n";
print "\n";
print "
print "\n";
print "\n";
print "\n";
print "
print "
print "
my $bb = system("/home/ntop.sh stop");
sleep(5);
$cc = system("/home/ntop.sh start &");
print "";
print "";
exit($cc);
---------------------------------------------------------------------------------------
it works excellent from command line,
but it it doesn't start ntop via browser.
what's wrong ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 07:55 AM
тАО07-21-2005 07:55 AM
Re: I need a perl script to stop and start program
print "Status: ",$cc,"\n";
After the system call. You should at least then see the exit status. I suspect you are missing environment variables or ntop expects a tty device as stdin. Put probes that write to a file in your ntop.sh script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 08:09 AM
тАО07-21-2005 08:09 AM
Re: I need a perl script to stop and start program
Status: 0 ntop
I think the www user has no rights
to execute "system" via browser,
because I have in the Apache error log:
[Thu Jul 21 23:43:54 2005] [error] [client 192.168.0.105] Permission denied
do you know howto change that ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 08:12 AM
тАО07-21-2005 08:12 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
тАО07-21-2005 08:21 AM
тАО07-21-2005 08:21 AM
Re: I need a perl script to stop and start program
total 602
-rw-r--r-- 1 root wheel 32 Jul 19 12:55 .directory
drwxr-xr-x 3 root wheel 512 Jul 18 22:54 .java
drwxr-xr-x 2 root wheel 512 Jul 20 23:02 X11
lrwxrwxrwx 1 root wheel 12 Jul 15 23:38 aliases -> mail/aliases
-rw-r--r-- 1 root wheel 65536 Jul 18 19:04 aliases.db
-rw-r--r-- 1 root wheel 209 May 8 09:05 amd.map
-rw-r--r-- 1 root wheel 1234 May 8 09:05 apmd.conf
-rw-r--r-- 1 root wheel 231 May 8 09:05 auth.conf
drwxr-xr-x 2 root wheel 512 Jul 15 23:38 bluetooth
-rw-r--r-- 1 root wheel 737 May 8 09:05 crontab
-rw-r--r-- 1 root wheel 108 May 8 09:05 csh.cshrc
-rw-r--r-- 1 root wheel 481 May 8 09:05 csh.login
-rw-r--r-- 1 root wheel 110 May 8 09:05 csh.logout
drwxr-xr-x 2 root wheel 512 Jul 15 23:38 defaults
-rw-r--r-- 1 root wheel 4846 May 8 09:05 devd.conf
-rw-r--r-- 1 root wheel 2071 May 8 09:05 devfs.conf
-rw-r--r-- 1 root wheel 267 May 8 09:05 dhclient.conf
-rw-r--r-- 1 root wheel 6621 May 8 09:05 disktab
-rw-rw-r-- 1 root operator 0 May 8 09:05 dumpdates
-rw-r--r-- 1 root wheel 142 May 8 09:05 fbtab
-rw-r--r-- 1 root wheel 391 Jul 15 23:50 fstab
-rw-r--r-- 1 root wheel 245 May 8 09:05 ftpusers
-rw-r--r-- 1 root wheel 5904 May 8 09:05 gettytab
drwxr-xr-x 2 root wheel 512 Jul 15 23:38 gnats
-rw-r--r-- 1 root wheel 489 Jul 16 15:09 group
-rw-r--r-- 1 root wheel 60 Jul 15 22:29 host.conf
-rw-r--r-- 1 root wheel 146 Jul 20 21:25 hosts
-rw-r--r-- 1 root wheel 3237 Jul 21 01:39 hosts.allow
-rw-r--r-- 1 root wheel 111 May 8 09:05 hosts.equiv
-rw-r--r-- 1 root wheel 99 May 8 09:05 hosts.lpd
-rw-r--r-- 1 root wheel 5319 May 8 09:05 inetd.conf
drwx------ 2 root wheel 512 Jul 15 23:38 isdn
-rw-r--r-- 1 root wheel 837 May 8 09:03 localtime
-rw-r--r-- 1 root wheel 619 May 8 09:05 locate.rc
-rw-r--r-- 1 root wheel 1847 May 8 09:05 login.access
-rw-r--r-- 1 root wheel 6522 May 8 09:05 login.conf
-rw-r--r-- 1 root wheel 65536 May 8 09:05 login.conf.db
-rw-r--r-- 1 root wheel 564 May 8 09:05 mac.conf
drwxr-xr-x 2 root wheel 512 Jul 17 12:51 mail
-rw-r--r-- 1 root wheel 106 May 8 09:05 mail.rc
-rw-r--r-- 1 root wheel 91 Jul 18 19:09 make.conf
-rw-r--r-- 1 root wheel 0 Jul 16 15:20 make.conf.bak
-rw-r--r-- 1 root wheel 1087 Jul 16 15:27 manpath.config
-rw-r--r-- 1 root wheel 946 Jul 16 15:20 manpath.config.bak
-rw------- 1 root wheel 1845 Jul 21 00:20 master.passwd
-rw-r--r-- 1 root wheel 1114 Jul 15 22:29 motd
drwxr-xr-x 2 root wheel 512 Jul 15 23:38 mtree
lrwxrwxrwx 1 root wheel 23 Jul 15 23:38 namedb -> ../var/named/etc/namedb
-rw-r--r-- 1 root wheel 783 May 8 09:05 netconfig
-rwxr-xr-x 1 root wheel 2362 May 8 09:05 netstart
-rw-r--r-- 1 root wheel 13696 May 8 09:05 network.subr
-rw-r--r-- 1 root wheel 365 May 8 09:05 networks
-rw-r--r-- 1 root wheel 1937 May 8 09:05 newsyslog.conf
-rw------- 1 root wheel 1701 May 8 09:05 nsmb.conf
-rw-r--r-- 1 root wheel 113 Jul 15 22:29 nsswitch.conf
drwx------ 2 root wheel 512 May 8 09:00 ntp
-rw------- 1 root wheel 432 May 8 09:05 opieaccess
-rw-r--r-- 1 root wheel 0 Jul 15 22:36 opiekeys
drwxr-xr-x 2 root wheel 512 Jul 15 23:38 pam.d
-rw-r--r-- 1 root wheel 1607 Jul 21 00:20 passwd
-rwxr-xr-x 1 root wheel 5814 May 8 09:05 pccard_ether
drwxr-xr-x 6 root wheel 512 Jul 15 23:38 periodic
-rw-r--r-- 1 root wheel 177 Jul 18 19:22 periodic.conf
-rw-r--r-- 1 root wheel 3567 May 8 09:05 pf.conf
-rw-r--r-- 1 root wheel 22556 May 8 09:05 pf.os
-rw-r--r-- 1 root wheel 293 May 8 09:05 phones
drwxr-xr-x 2 root wheel 512 Jul 15 23:38 ppp
-rw-r--r-- 1 root wheel 2058 May 8 09:05 printcap
-rw-r--r-- 1 root wheel 619 May 8 09:05 profile
-rw-r--r-- 1 root wheel 5807 May 8 09:05 protocols
-rw-r--r-- 1 root wheel 40960 Jul 21 00:20 pwd.db
-rw-r--r-- 1 root wheel 2716 May 8 09:05 rc
-rw-r--r-- 1 root wheel 5298 May 8 09:05 rc.bsdextended
-rw-r--r-- 1 root wheel 942 Jul 20 21:33 rc.conf
-rw-r--r-- 1 root wheel 1114 Jul 20 21:25 rc.conf~
drwxr-xr-x 2 root wheel 2560 Jul 15 23:38 rc.d
-rw-r--r-- 1 root wheel 9569 May 8 09:05 rc.firewall
-rw-r--r-- 1 root wheel 8905 May 8 09:05 rc.firewall6
-rwxr-xr-x 1 root wheel 2165 May 8 09:05 rc.resume
-rw-r--r-- 1 root wheel 5785 May 8 09:05 rc.sendmail
-rw-r--r-- 1 root wheel 3211 May 8 09:05 rc.shutdown
-rw-r--r-- 1 root wheel 30905 May 8 09:05 rc.subr
-rwxr-xr-x 1 root wheel 2209 May 8 09:05 rc.suspend
-rw-r--r-- 1 root wheel 2392 May 8 09:05 remote
-rw-r--r-- 1 root wheel 42 Jul 20 21:25 resolv.conf
lrwxrwxrwx 1 root wheel 13 Jul 15 23:38 rmt -> /usr/sbin/rmt
-rw-r--r-- 1 root wheel 1674 May 8 09:05 rpc
-rw-r--r-- 1 root wheel 73410 May 8 09:05 services
-rw-r--r-- 1 root wheel 237 Jul 16 00:04 shells
drwxr-xr-x 2 root wheel 512 May 8 09:00 skel
-rw------- 1 root wheel 40960 Jul 21 00:20 spwd.db
drwxr-xr-x 2 root wheel 512 Jul 15 22:34 ssh
drwxr-xr-x 2 root wheel 512 Jul 15 23:38 ssl
-rw-r--r-- 1 root wheel 367 May 8 09:05 sysctl.conf
-rw-r--r-- 1 root wheel 1339 May 8 09:05 syslog.conf
lrwxrwxrwx 1 root wheel 23 Jul 15 23:38 termcap -> /usr/share/misc/termcap
-rw-r--r-- 1 root wheel 13 Jul 20 22:48 timezone
-rw-r--r-- 1 root wheel 7658 May 8 09:05 ttys
-rw-r--r-- 1 root wheel 2032 May 8 09:05 usbd.conf
-r--r--r-- 1 root wheel 0 Jul 15 23:42 wall_cmos_clock
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-21-2005 08:27 AM
тАО07-21-2005 08:27 AM