<?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 Re: shell script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643540#M102604</link>
    <description>do you want to store success results in one file and failure results in one file so that you can keep track?&lt;BR /&gt;&lt;BR /&gt;Without this, you can grep like,&lt;BR /&gt;&lt;BR /&gt;grep 'Success' /tmp/iplookup.log&lt;BR /&gt;grep 'Failed' /tmp/iplookup.log&lt;BR /&gt;&lt;BR /&gt;to get results.&lt;BR /&gt;&lt;BR /&gt;If it is not your requirement then revert here.&lt;BR /&gt;&lt;BR /&gt;thx.</description>
    <pubDate>Tue, 18 Oct 2005 01:19:52 GMT</pubDate>
    <dc:creator>Muthukumar_5</dc:creator>
    <dc:date>2005-10-18T01:19:52Z</dc:date>
    <item>
      <title>shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643528#M102592</link>
      <description>Dear Sirs;&lt;BR /&gt;&lt;BR /&gt;I need a script for the following situation.&lt;BR /&gt;&lt;BR /&gt;Want to run nslookup xx.xx.xx.xx ( this is a virtual ip address )&lt;BR /&gt;if it returns&lt;BR /&gt;12.16.91.93 &lt;BR /&gt;Then no problem and output should go to a file for recording&lt;BR /&gt;if it returns&lt;BR /&gt;14.16.17.22&lt;BR /&gt;then it should say "problem" and send the email alert to xxyy.zz@abc.com&lt;BR /&gt;(sendmail is already running on the box)&lt;BR /&gt;The message should also get recorded in the above mentioned file&lt;BR /&gt;&lt;BR /&gt;check for the size of this file if size is say more than 2mb; it should delete the file and record in a new file&lt;BR /&gt; &lt;BR /&gt;this script should be running after every 25 seconds.&lt;BR /&gt;&lt;BR /&gt;I  don't want to run this script as a cron job.&lt;BR /&gt;&lt;BR /&gt;Please suggest.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Shiv</description>
      <pubDate>Thu, 06 Oct 2005 13:14:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643528#M102592</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2005-10-06T13:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643529#M102593</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Scripting part is seperate but I do not think it would be possible to schedule it without cron. Also the frequency is also very less as minimum for the cron to work is 1 minute.&lt;BR /&gt;&lt;BR /&gt;Just curious to see some responses for the same.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Devender</description>
      <pubDate>Thu, 06 Oct 2005 13:25:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643529#M102593</guid>
      <dc:creator>Devender Khatana</dc:creator>
      <dc:date>2005-10-06T13:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643530#M102594</link>
      <description>The scheduling can be done with at, but not at 25 second intervals. Like cron, the smallest interval at deals with is minutes.&lt;BR /&gt;&lt;BR /&gt;echo "script_name" | at now + 1 minute&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Thu, 06 Oct 2005 13:34:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643530#M102594</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2005-10-06T13:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643531#M102595</link>
      <description>Hi,&lt;BR /&gt;I remember a similar problem for some time ago. A possible solution is to run the script from inittab. Put a sleep 25 statment at the end of the script and use the respawn option in inittab (see /etc/inittab for examples).</description>
      <pubDate>Thu, 06 Oct 2005 13:36:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643531#M102595</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2005-10-06T13:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643532#M102596</link>
      <description>I would create a perl script using exec or eval to execute your script, sleep for 25 seconds and execute again...&lt;BR /&gt;&lt;BR /&gt;Good luck!</description>
      <pubDate>Thu, 06 Oct 2005 14:14:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643532#M102596</guid>
      <dc:creator>cilene Peterson</dc:creator>
      <dc:date>2005-10-06T14:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643533#M102597</link>
      <description>I would create a perl script using exec or eval to execute your script, sleep for 25 seconds and execute again...&lt;BR /&gt;&lt;BR /&gt;Of course this would be a loop forever program...&lt;BR /&gt;&lt;BR /&gt;Good luck!</description>
      <pubDate>Thu, 06 Oct 2005 14:17:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643533#M102597</guid>
      <dc:creator>cilene Peterson</dc:creator>
      <dc:date>2005-10-06T14:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643534#M102598</link>
      <description>Can someone please suggest the shell script code ?&lt;BR /&gt;&lt;BR /&gt;Thanks and regards,&lt;BR /&gt;Shiv</description>
      <pubDate>Thu, 06 Oct 2005 14:37:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643534#M102598</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2005-10-06T14:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643535#M102599</link>
      <description>while true&lt;BR /&gt;do  #start of forever loop&lt;BR /&gt;IPADR=`nslookup | grep Address | awk {'print $2'}`&lt;BR /&gt;if [ "$IPADR" = "12.16.91.93" ]&lt;BR /&gt;then&lt;BR /&gt; (printf "Everything is fine at ";date) &amp;gt;&amp;gt; /tmp/mylogfile&lt;BR /&gt;else &lt;BR /&gt;if [ "$IPADR" = "14.16.17.22" ]&lt;BR /&gt;then&lt;BR /&gt;echo problem | sendmail xxyy.zz@abc.com&lt;BR /&gt;(echo "PROBLEM ENCOUNTERED at ";date) &amp;gt;&amp;gt; /tmp/mylogfile&lt;BR /&gt;else&lt;BR /&gt;(echo "UNKNOWN IP RETURNED at ";date) &amp;gt;&amp;gt; /tmp/mylogfile&lt;BR /&gt;fi&lt;BR /&gt;fi&lt;BR /&gt;sleep 25&lt;BR /&gt;&lt;BR /&gt;LOGSIZE=`ll /tmp/mylogfile | awk {'print $5'}`&lt;BR /&gt;if [ $LOGSIZE -ge 2000000 ] &lt;BR /&gt;then&lt;BR /&gt;cat /dev/null &amp;gt; /tmp/mylogfile # zero it out&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;done  # repeat forever&lt;BR /&gt;&lt;BR /&gt;if I were you I would move the logfile to .old extension for future examination and then zero it out, but this is only my opinion&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hope this helps</description>
      <pubDate>Thu, 06 Oct 2005 14:37:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643535#M102599</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2005-10-06T14:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643536#M102600</link>
      <description>Just a thought ... Mel's script will keep sending an email out every 25 seconds until the issue is corrected.  You may want to tailor the code to do otherwise.</description>
      <pubDate>Thu, 06 Oct 2005 15:08:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643536#M102600</guid>
      <dc:creator>Tom Danzig</dc:creator>
      <dc:date>2005-10-06T15:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643537#M102601</link>
      <description>This is not a super challenging script but to write it you need to specify a few more things&lt;BR /&gt;&lt;BR /&gt;I assume you are just testing your DNS server or servers and actually fixing that would be the real solution but till then lets get on with it.&lt;BR /&gt;&lt;BR /&gt;First you want a script that is going to loop every 25 seconds or so but you probably don't want it to loop for ever and ever till the end of time.  That can be done with a stop file in the /tmp directory&lt;BR /&gt;&lt;BR /&gt;#!ksh&lt;BR /&gt;&lt;BR /&gt;while [ ! -f /tmp/mystopfile ]&lt;BR /&gt; do&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#do some stuff&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sleep 25 &lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;now all you have to do is touch /tmp/mystop and the loop will drop out and stop the script&lt;BR /&gt;&lt;BR /&gt;next, the business end doing the nslookup and deciding based on the results what to do&lt;BR /&gt;&lt;BR /&gt;I don't know what nslookup version you are using or what switches so I will leave up to you to filter down to just the IP address&lt;BR /&gt;&lt;BR /&gt;IPTRACKERLOG=/tmp/iptrackerlog&lt;BR /&gt;If [ wc -l $IPTRACKERLOG &amp;gt; 1000 ] &lt;BR /&gt;then &lt;BR /&gt;echo "log restart `date` " &amp;gt; $IPTRACKERLOG&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;IPADDR=`nslookup xx.xx.xx.xx | grep Address | cut c11-`&lt;BR /&gt;&lt;BR /&gt;If [ $IPADDR = "12.16.91.93" ]&lt;BR /&gt;Then&lt;BR /&gt;Echo "all is well with IP $IPADDR `date`" &amp;gt;&amp;gt; $IPTRACKERLOG&lt;BR /&gt;&lt;BR /&gt;#I assume anything but this response is cause for concern so&lt;BR /&gt;else&lt;BR /&gt;echo "ERROR &amp;gt;&amp;gt;&amp;gt; tracker found IP $IPADDR `date`" &amp;gt;&amp;gt; $IPTRACKERLOG&lt;BR /&gt;&lt;BR /&gt;#you may want to put a stop file here too and have it set its own otherwise you will get a message every 25 seconds till the script stops or the problem is fixed.&lt;BR /&gt;echo "your ip tracker thing on the hpux server got an error" | mailx -s "your ip check script" usr@address.com &lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;legal notice:  I don't guarantee any of these commands to work the way they are listed they are here for novelty purposes only and should never actually be used till you have tested and modified them to suit your needs and even then, if it all goes bad, its still not my fault.&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Oct 2005 15:27:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643537#M102601</guid>
      <dc:creator>Howard Marshall</dc:creator>
      <dc:date>2005-10-06T15:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643538#M102602</link>
      <description>You can try as,&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;stime=25&lt;BR /&gt;&lt;BR /&gt;# User input&lt;BR /&gt;ipaddress=""&lt;BR /&gt;logfile=/tmp/iplookup.log&lt;BR /&gt;mailID="xxyy.zz@abc.com"&lt;BR /&gt;&lt;BR /&gt;while [ 1 ]&lt;BR /&gt;do&lt;BR /&gt;  &lt;BR /&gt;  nslookup $ipaddress | grep -qE '12.16.91.93'&lt;BR /&gt;  if [ $? -eq 0 ]&lt;BR /&gt;  then&lt;BR /&gt;    echo "Lookup Success @ $(date)" &amp;gt;&amp;gt; $logfile&lt;BR /&gt;  fi&lt;BR /&gt;  &lt;BR /&gt;  nslookup $ipaddress | grep -qE '14.16.17.22'&lt;BR /&gt;  if [ $? -eq 0 ]&lt;BR /&gt;  then&lt;BR /&gt;    echo "Lookup Failed @ $(date)" &amp;gt;&amp;gt; $logfile&lt;BR /&gt;    echo "Lookup Problem @ $(date)" | mailx -s"Problem" ${mailID}&lt;BR /&gt;  fi&lt;BR /&gt;  &lt;BR /&gt;  ret=$(ls -l $logfile | awk '{ size=$5/1048576; if ( size &amp;gt; 2 ) { print "1"; } else { print "2";}}')&lt;BR /&gt;  &lt;BR /&gt;  if [ $ret -eq 1 ]&lt;BR /&gt;  then&lt;BR /&gt;    cat $logfile &amp;gt;&amp;gt; $logfile.old&lt;BR /&gt;  fi&lt;BR /&gt;  &lt;BR /&gt;  sleep $stime&lt;BR /&gt;  &lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;# END&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Fri, 07 Oct 2005 00:55:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643538#M102602</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-10-07T00:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643539#M102603</link>
      <description>Muthukumar; i used your script.&lt;BR /&gt;i got the output as :&lt;BR /&gt;Lookup Success @ Mon Oct 17 23:11:25 PDT 2005&lt;BR /&gt;Lookup Success @ Mon Oct 17 23:11:50 PDT 2005&lt;BR /&gt;&lt;BR /&gt;now suppose i want to show ip address also against success and failure in the log file then how to modify this script ?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Shiv</description>
      <pubDate>Tue, 18 Oct 2005 01:15:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643539#M102603</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2005-10-18T01:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643540#M102604</link>
      <description>do you want to store success results in one file and failure results in one file so that you can keep track?&lt;BR /&gt;&lt;BR /&gt;Without this, you can grep like,&lt;BR /&gt;&lt;BR /&gt;grep 'Success' /tmp/iplookup.log&lt;BR /&gt;grep 'Failed' /tmp/iplookup.log&lt;BR /&gt;&lt;BR /&gt;to get results.&lt;BR /&gt;&lt;BR /&gt;If it is not your requirement then revert here.&lt;BR /&gt;&lt;BR /&gt;thx.</description>
      <pubDate>Tue, 18 Oct 2005 01:19:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643540#M102604</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-10-18T01:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643541#M102605</link>
      <description>nslookup $ipaddress | grep -qE '12.16.91.93'&lt;BR /&gt;if [ $? -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo "Lookup Success for $ipaddress @ $(date)" &amp;gt;&amp;gt; $logfile&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;nslookup $ipaddress | grep -qE '14.16.17.22'&lt;BR /&gt;if [ $? -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo "Lookup Failed for $ipaddress @ $(date)" &amp;gt;&amp;gt; $logfile&lt;BR /&gt;echo "Lookup Problem  for $ipaddress @ $(date)" | mailx -s"Problem" ${mailID}&lt;BR /&gt;fi</description>
      <pubDate>Tue, 18 Oct 2005 01:33:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643541#M102605</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2005-10-18T01:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643542#M102606</link>
      <description>great arun ;)&lt;BR /&gt;&lt;BR /&gt;Just change script echo statements with ${ipaddress} to get your desired output with IP-Address.&lt;BR /&gt;&lt;BR /&gt;hth. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Oct 2005 01:49:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643542#M102606</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-10-18T01:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: shell script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643543#M102607</link>
      <description>Shiv, &lt;BR /&gt;&lt;BR /&gt;I use a process to page me in the event our primary DNS server fails.. &lt;BR /&gt;&lt;BR /&gt;if the NS lookup fails to return xxx.xxx.xxx.xxx then I have the system send me a page via my email pager.. Works great. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/bin/bash &lt;BR /&gt;ns=`nslookup -sil &lt;A href="http://www.yourwebserver.xxx" target="_blank"&gt;www.yourwebserver.xxx&lt;/A&gt; |head -1  |awk '{print $2}'` &lt;BR /&gt;if [  "$ns" != "xxx.xxx.xxx.xxx" ] &lt;BR /&gt;then &lt;BR /&gt;echo "Lookup failed" &amp;gt; lookup.txt&lt;BR /&gt;mail -v -s "xxx.xxx.xxx.xxx failed `date +%Y%m%d:%H%M`" name@email.xxx &amp;lt; lookup.txt&lt;BR /&gt;fi</description>
      <pubDate>Fri, 04 Nov 2005 09:48:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/shell-script/m-p/3643543#M102607</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2005-11-04T09:48:05Z</dc:date>
    </item>
  </channel>
</rss>

