<?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 Shell Script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/5070966#M438726</link>
    <description>I am writing a script to get yesterdays users who are logged in.&lt;BR /&gt;The script works fine but need to make few changes to the script so that it echo “No users Yesterdays users logged in” if it finds no user from yesterday logged and should display yesterdays users if they are logged in&lt;BR /&gt;&lt;BR /&gt;See example below:&lt;BR /&gt;&lt;BR /&gt;Check if yesterdays users still logged&lt;BR /&gt;============================================================= &lt;BR /&gt;gmt1        pts/7        Sep 25 09:58  0:37  24165  dev1:1.0&lt;BR /&gt;&lt;BR /&gt;Check if any critical errors in syslog&lt;BR /&gt;============================================================= &lt;BR /&gt;&lt;BR /&gt;and I get this O/P when no users logged in and no errors&lt;BR /&gt;&lt;BR /&gt;Check if yesterdays users still logged&lt;BR /&gt;============================================================= &lt;BR /&gt;Check if any critical errors in syslog&lt;BR /&gt;============================================================= &lt;BR /&gt;&lt;BR /&gt;How can I make changes to the script so that if no errors then it should display as below&lt;BR /&gt;&lt;BR /&gt;Check if yesterdays users still logged&lt;BR /&gt;============================================================= &lt;BR /&gt;No yesterdays users logged&lt;BR /&gt;&lt;BR /&gt;Check if any crucial erros in syslog&lt;BR /&gt;============================================================= &lt;BR /&gt;No critical errors logged&lt;BR /&gt;&lt;BR /&gt;Part of my script as below:&lt;BR /&gt;&lt;BR /&gt;#This function checks if yesterdays users were killed by OPS&lt;BR /&gt;function check_yesterday_users&lt;BR /&gt;{&lt;BR /&gt;        echo &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;        echo "Check if yesterdays users still logged" &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;        echo "===============================" &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;        echo &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;        who -u | grep "$1" &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;}&lt;BR /&gt; &lt;BR /&gt;</description>
    <pubDate>Wed, 26 Sep 2007 09:59:12 GMT</pubDate>
    <dc:creator>Aggy</dc:creator>
    <dc:date>2007-09-26T09:59:12Z</dc:date>
    <item>
      <title>Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/5070966#M438726</link>
      <description>I am writing a script to get yesterdays users who are logged in.&lt;BR /&gt;The script works fine but need to make few changes to the script so that it echo “No users Yesterdays users logged in” if it finds no user from yesterday logged and should display yesterdays users if they are logged in&lt;BR /&gt;&lt;BR /&gt;See example below:&lt;BR /&gt;&lt;BR /&gt;Check if yesterdays users still logged&lt;BR /&gt;============================================================= &lt;BR /&gt;gmt1        pts/7        Sep 25 09:58  0:37  24165  dev1:1.0&lt;BR /&gt;&lt;BR /&gt;Check if any critical errors in syslog&lt;BR /&gt;============================================================= &lt;BR /&gt;&lt;BR /&gt;and I get this O/P when no users logged in and no errors&lt;BR /&gt;&lt;BR /&gt;Check if yesterdays users still logged&lt;BR /&gt;============================================================= &lt;BR /&gt;Check if any critical errors in syslog&lt;BR /&gt;============================================================= &lt;BR /&gt;&lt;BR /&gt;How can I make changes to the script so that if no errors then it should display as below&lt;BR /&gt;&lt;BR /&gt;Check if yesterdays users still logged&lt;BR /&gt;============================================================= &lt;BR /&gt;No yesterdays users logged&lt;BR /&gt;&lt;BR /&gt;Check if any crucial erros in syslog&lt;BR /&gt;============================================================= &lt;BR /&gt;No critical errors logged&lt;BR /&gt;&lt;BR /&gt;Part of my script as below:&lt;BR /&gt;&lt;BR /&gt;#This function checks if yesterdays users were killed by OPS&lt;BR /&gt;function check_yesterday_users&lt;BR /&gt;{&lt;BR /&gt;        echo &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;        echo "Check if yesterdays users still logged" &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;        echo "===============================" &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;        echo &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;        who -u | grep "$1" &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;}&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Wed, 26 Sep 2007 09:59:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/5070966#M438726</guid>
      <dc:creator>Aggy</dc:creator>
      <dc:date>2007-09-26T09:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/5070967#M438727</link>
      <description>echo &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;echo "Check if yesterdays users still logged" &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;echo "===============================" &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;echo &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;who -u | grep "$1" &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;&lt;BR /&gt;add immediately after the line above:&lt;BR /&gt;&lt;BR /&gt;if [ $? = 1 ]&lt;BR /&gt;then&lt;BR /&gt;   echo "No yesterdays users still logged" &amp;gt;&amp;gt; $LOGFILE&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;the grep will return 1 if no matches found, 0 if they are.  similar logic applys to the syslog error piece&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Sep 2007 10:26:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/5070967#M438727</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2007-09-26T10:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/5070968#M438728</link>
      <description>I am not going to bother to answer your specific questions because there is a fundamental flaw in your design. You are relying upon the "who" command to tell you who is on the system. Regardless of the UNIX flavor, who is the system's "best guess" as to who is actually on the system. Using who, your script will work well almost all the time --- which is the worst kind of problem to debug. Sure you can use fwtmp to fix utmp when users are not logged off cleanly but you are really just fixing the symptoms of the problem. Rather than using who, use the process table (ps command) because it is reliable and trustworthy.</description>
      <pubDate>Wed, 26 Sep 2007 10:29:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/5070968#M438728</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-09-26T10:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/5070969#M438729</link>
      <description>Thanks</description>
      <pubDate>Wed, 26 Sep 2007 10:39:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/5070969#M438729</guid>
      <dc:creator>Aggy</dc:creator>
      <dc:date>2007-09-26T10:39:12Z</dc:date>
    </item>
  </channel>
</rss>

