<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Script Help in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3315005#M12858</link>
    <description>Hi gurus,&lt;BR /&gt;&lt;BR /&gt;I can't see any problem in my below perl script. There are 4 rsyn deamons. My script to check if 4 &lt;BR /&gt;daemons are running.&lt;BR /&gt;&lt;BR /&gt;#!/bin/perl&lt;BR /&gt;my $CMD;&lt;BR /&gt;$CMD=system("ps -ef |grep -v grep |grep rsync |wc -l");&lt;BR /&gt;if ($CMD != 4)&lt;BR /&gt;       {&lt;BR /&gt;          print "There should 4 rsync daemons running, only x process running\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;But the script prints message even there are 4 daemons running. I know it's a basic and simple script but I am missing something.&lt;BR /&gt;Can someone point me the problem?. System is RH9.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Siva</description>
    <pubDate>Thu, 24 Jun 2004 21:36:05 GMT</pubDate>
    <dc:creator>Sivasingam Santhakumar</dc:creator>
    <dc:date>2004-06-24T21:36:05Z</dc:date>
    <item>
      <title>Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3315005#M12858</link>
      <description>Hi gurus,&lt;BR /&gt;&lt;BR /&gt;I can't see any problem in my below perl script. There are 4 rsyn deamons. My script to check if 4 &lt;BR /&gt;daemons are running.&lt;BR /&gt;&lt;BR /&gt;#!/bin/perl&lt;BR /&gt;my $CMD;&lt;BR /&gt;$CMD=system("ps -ef |grep -v grep |grep rsync |wc -l");&lt;BR /&gt;if ($CMD != 4)&lt;BR /&gt;       {&lt;BR /&gt;          print "There should 4 rsync daemons running, only x process running\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;But the script prints message even there are 4 daemons running. I know it's a basic and simple script but I am missing something.&lt;BR /&gt;Can someone point me the problem?. System is RH9.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Siva</description>
      <pubDate>Thu, 24 Jun 2004 21:36:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3315005#M12858</guid>
      <dc:creator>Sivasingam Santhakumar</dc:creator>
      <dc:date>2004-06-24T21:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3315006#M12859</link>
      <description>What you're doing here is getting the handle on a system process, not on the output of a given command.  To do that, you need to open the command in a pipe, similar to:&lt;BR /&gt;&lt;BR /&gt;open( FH, "ps -ef | grep -v grep | grep rsync | wc -l |" );&lt;BR /&gt;$output = &lt;FH&gt;;&lt;BR /&gt;if ($output != &lt;SOMETHING&gt;) {&lt;BR /&gt;print "blah\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;-- (Be aware, that 'wc -l' outputs spaces/tabs infront of your number, so you'd need to clean it up a fair bit first, or possibly just use 'ps -ef | grep -v grep | grep -c rsync' instead).&lt;BR /&gt;&lt;BR /&gt;Although if you're going to be doing something like this, why use a perl script?&lt;BR /&gt;&lt;BR /&gt;As a simple shell script, something like:&lt;BR /&gt;&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;if [ "$(ps -ef | grep -v grep | grep -c rsync)" -ne 4 ]&lt;BR /&gt;then&lt;BR /&gt;echo "There should be 4"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Just some thoughts.&lt;/SOMETHING&gt;&lt;/FH&gt;</description>
      <pubDate>Thu, 24 Jun 2004 21:43:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3315006#M12859</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2004-06-24T21:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3315007#M12860</link>
      <description>Stuart,&lt;BR /&gt;&lt;BR /&gt;Thanks for the quick one and the explanation. I need to use perl because of the email function.&lt;BR /&gt;&lt;BR /&gt;Thanks again&lt;BR /&gt;Siva</description>
      <pubDate>Thu, 24 Jun 2004 23:15:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3315007#M12860</guid>
      <dc:creator>Sivasingam Santhakumar</dc:creator>
      <dc:date>2004-06-24T23:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3315008#M12861</link>
      <description>Fair enough.&lt;BR /&gt;&lt;BR /&gt;With a little playing though, you can get email out of shell scripts just as easily (pipe the body of a message into the 'mail' command *shrug*).&lt;BR /&gt;&lt;BR /&gt;If you're happy using perl though, stick with it!  It's truely a fabulous language!</description>
      <pubDate>Thu, 24 Jun 2004 23:57:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3315008#M12861</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2004-06-24T23:57:56Z</dc:date>
    </item>
  </channel>
</rss>

