Plankton has asked for the wisdom of the Perl Monks concerning the following question:
Friends
I want to translate a small bit of shell script to Perl.
Here's what I have in my shell script ...
... Here's my lame attempt to translate this to Perl ...... PID=`cat /var/log/syslogd.pid` RUNNING=`ps -ef | grep -v grep | grep $PID | wc -l` if [ $RUNNING != 1 ] then echo "syslog not running" fi ...
... well that doesn't work to well and I suspect that the monks know a way-better way to do something like this. Can you help? :)sub is_syslogd_running { my $cmd = "ps -ef | grep -v grep | grep `cat /var/run/syslogd.pid`" +; my $rc = 1; open CMD, $cmd or return $rc; while( <CMD> ) { $rc = 0; } return $rc; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How best to see if syslogd is running?
by Fletch (Bishop) on Jan 03, 2005 at 20:51 UTC | |
by bluto (Curate) on Jan 03, 2005 at 21:47 UTC | |
|
Re: How best to see if syslogd is running?
by ambrus (Abbot) on Jan 03, 2005 at 21:08 UTC | |
by Fletch (Bishop) on Jan 03, 2005 at 21:33 UTC | |
|
Re: How best to see if syslogd is running?
by sgifford (Prior) on Jan 04, 2005 at 03:08 UTC | |
|
Re: How best to see if syslogd is running? (use Perl!)
by grinder (Bishop) on Jan 04, 2005 at 09:29 UTC | |
|
Re: How best to see if syslogd is running?
by bageler (Hermit) on Jan 04, 2005 at 03:12 UTC | |
|
Re: How best to see if syslogd is running?
by Anonymous Monk on Jan 04, 2005 at 10:25 UTC | |
|
Re: How best to see if syslogd is running?
by BravoTwoZero (Scribe) on Jan 04, 2005 at 16:28 UTC | |
by bluto (Curate) on Jan 04, 2005 at 16:51 UTC |