<?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: Scripting in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689964#M794971</link>
    <description>Not too difficult. Put the following in a file, make it executable (chmod u+x script_name), and schedule it in cron:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;SERVER_LIST=$(cat server_list_file)&lt;BR /&gt;&lt;BR /&gt;for SERVER in ${SERVER_LIST}&lt;BR /&gt;do&lt;BR /&gt;  /etc/ping ${SERVER} -n 1 &amp;gt; /dev/null&lt;BR /&gt;  RC=$?&lt;BR /&gt;&lt;BR /&gt;  if [ ${RC} -ne 0 ];&lt;BR /&gt;  then&lt;BR /&gt;    echo "Ping to ${SERVER} failed!"&lt;BR /&gt;  fi&lt;BR /&gt;done</description>
    <pubDate>Mon, 12 Dec 2005 17:16:07 GMT</pubDate>
    <dc:creator>Jeff_Traigle</dc:creator>
    <dc:date>2005-12-12T17:16:07Z</dc:date>
    <item>
      <title>Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689962#M794969</link>
      <description>I'm looking for some help with a basic script.  I want to run a cron job to ping my servers and send out an email if the ping fails.  Any help would be greately apprecieated.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Darrell</description>
      <pubDate>Mon, 12 Dec 2005 17:09:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689962#M794969</guid>
      <dc:creator>Darrell K Miracle</dc:creator>
      <dc:date>2005-12-12T17:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689963#M794970</link>
      <description>Not too difficult. Put the following in a file, make it executable (chmod u+x script_name), and schedule it in cron:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;SERVER_LIST=$(cat server_list_file)&lt;BR /&gt;&lt;BR /&gt;for SERVER in ${SERVER_LIST}&lt;BR /&gt;do&lt;BR /&gt;  ping ${SERVER} -n 1 &amp;gt; /dev/null&lt;BR /&gt;  RC=$?&lt;BR /&gt;&lt;BR /&gt;  if [ ${RC} -ne 0 ];&lt;BR /&gt;  then&lt;BR /&gt;    echo "Ping to ${SERVER} failed!"&lt;BR /&gt;  fi&lt;BR /&gt;done</description>
      <pubDate>Mon, 12 Dec 2005 17:15:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689963#M794970</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2005-12-12T17:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689964#M794971</link>
      <description>Not too difficult. Put the following in a file, make it executable (chmod u+x script_name), and schedule it in cron:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;SERVER_LIST=$(cat server_list_file)&lt;BR /&gt;&lt;BR /&gt;for SERVER in ${SERVER_LIST}&lt;BR /&gt;do&lt;BR /&gt;  /etc/ping ${SERVER} -n 1 &amp;gt; /dev/null&lt;BR /&gt;  RC=$?&lt;BR /&gt;&lt;BR /&gt;  if [ ${RC} -ne 0 ];&lt;BR /&gt;  then&lt;BR /&gt;    echo "Ping to ${SERVER} failed!"&lt;BR /&gt;  fi&lt;BR /&gt;done</description>
      <pubDate>Mon, 12 Dec 2005 17:16:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689964#M794971</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2005-12-12T17:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689965#M794972</link>
      <description>Darn system glitches... use the second one. Since you have a minimal PATH in the cron environment, you need to specify the full path for the ping command.</description>
      <pubDate>Mon, 12 Dec 2005 17:18:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689965#M794972</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2005-12-12T17:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689966#M794973</link>
      <description>For the mail part, just change the above line from:&lt;BR /&gt;&lt;BR /&gt;echo "Ping to ${SERVER} failed!"&lt;BR /&gt;&lt;BR /&gt;to&lt;BR /&gt;&lt;BR /&gt;mailx -s "Ping to ${SERVER} failed!" you@yourdomain.com&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 12 Dec 2005 17:29:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689966#M794973</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2005-12-12T17:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689967#M794974</link>
      <description>For the mail part, just change the above line from:&lt;BR /&gt;&lt;BR /&gt;echo "Ping to ${SERVER} failed!"&lt;BR /&gt;&lt;BR /&gt;to&lt;BR /&gt;&lt;BR /&gt;mailx -s "Ping to ${SERVER} failed!" you@yourdomain.com &lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 12 Dec 2005 17:29:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689967#M794974</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2005-12-12T17:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689968#M794975</link>
      <description>How does it get the IPs and how do I set it up to send email when it fails??</description>
      <pubDate>Mon, 12 Dec 2005 17:31:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689968#M794975</guid>
      <dc:creator>Darrell K Miracle</dc:creator>
      <dc:date>2005-12-12T17:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689969#M794976</link>
      <description>Hi Darrell:&lt;BR /&gt;&lt;BR /&gt;Using Jeff's script, build a file in the directory in which your script resides.  Now specify it's name as shown:&lt;BR /&gt;&lt;BR /&gt;SERVER_LIST=$(cat /yourdir/server_list_file)&lt;BR /&gt;&lt;BR /&gt;The file can contain either ipaddresses or hostnames (assuming that you have DNS configured) or both, like:&lt;BR /&gt;&lt;BR /&gt;10.11.10.123&lt;BR /&gt;herhost&lt;BR /&gt;hishost&lt;BR /&gt;10.11.10.456&lt;BR /&gt;&lt;BR /&gt;The script as written only looks at the first whitespace delimited field.&lt;BR /&gt;&lt;BR /&gt;Geoff's post after Jeff's tells you how to send the email notice.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 12 Dec 2005 17:47:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689969#M794976</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-12-12T17:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689970#M794977</link>
      <description>Can multipal email addresses be entered as follows.......&lt;BR /&gt;&lt;BR /&gt;darrell.miracle@us.army.mil; john.doe@us.army.mil; jan.doe@us.army.mil</description>
      <pubDate>Mon, 12 Dec 2005 17:53:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689970#M794977</guid>
      <dc:creator>Darrell K Miracle</dc:creator>
      <dc:date>2005-12-12T17:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689971#M794978</link>
      <description>Hi Darrell:&lt;BR /&gt;&lt;BR /&gt;Stack you multiple email destinations like this:&lt;BR /&gt;&lt;BR /&gt;darrell.miracle@us.army.mil  john.doe@us.army.mil jan.doe@us.army.mil&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;# mailx -s "Test!" &amp;lt; /dev/null darrell.miracle@us.army.mil  john.doe@us.army.mil jan.doe@us.army.mil&lt;BR /&gt;&lt;BR /&gt;...would send the three recipients a message with the subject line "Test!" but an empty message body.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 12 Dec 2005 18:06:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689971#M794978</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-12-12T18:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689972#M794979</link>
      <description>Another thing I like to do, is create a file with a list of admins in it then call it like so:&lt;BR /&gt;&lt;BR /&gt;mailx -s "Ping to ${SERVER} failed!" `cat /usr/local/mailadmin.list` &lt;BR /&gt;&lt;BR /&gt;That way, if you have multiple scripts, instead of updating each of them when you have to add or remove an admin - you only need to update 1 file - the mailadmin.list.&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Mon, 12 Dec 2005 19:07:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689972#M794979</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2005-12-12T19:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689973#M794980</link>
      <description>Darrell,&lt;BR /&gt;&lt;BR /&gt;Geoff uses a file to send to multiple email addresses;  I use an email alias, like so:&lt;BR /&gt;&lt;BR /&gt;In /etc/mail/aliases -- &lt;BR /&gt;&lt;BR /&gt;admins   : mark_ellzey@myco.com, other_admin@myco.com, yetanother_admin@myco.com&lt;BR /&gt;&lt;BR /&gt;Then you can do:&lt;BR /&gt;&lt;BR /&gt;mailx -s "Ping results" admins &amp;lt; message&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Mark&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 13 Dec 2005 10:00:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689973#M794980</guid>
      <dc:creator>Mark Ellzey</dc:creator>
      <dc:date>2005-12-13T10:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689974#M794981</link>
      <description>Mark - I used to use mail aliases - but more work to maintain - with a file - I can keep 1 master on a single server - then scp that file to all my other servers - with aliases - you might not want the same one on all servers...and if you do, it just means executing a newaliases command each time you change it (I know, only 1 extra step...).&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Tue, 13 Dec 2005 10:06:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689974#M794981</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2005-12-13T10:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689975#M794982</link>
      <description>Well, I was originally simplifying my assumption that the output from the echos would get emailed to the user running the script via cron. (stdout is emailed automatically.) Adding the mailx line to the echo will generate multiple emails if multiple failures occur in a single run. To reduce to a single email and be able to mail to any group of email addresses you want (comma separated in email_list_file in my example), you can modify it as follows. Tons of ways to do most things on UNIX, of course. Tkae your pick and go for it. :)&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;MSG_FILE=/var/tmp/ping_msg&lt;BR /&gt;SERVER_LIST=$(cat server_list_file)&lt;BR /&gt;EMAIL_LIST=$(cat email_list_file)&lt;BR /&gt;&lt;BR /&gt;for SERVER in ${SERVER_LIST}&lt;BR /&gt;do&lt;BR /&gt;/etc/ping ${SERVER} -n 1 &amp;gt; /dev/null&lt;BR /&gt;RC=$?&lt;BR /&gt;&lt;BR /&gt;if [ ${RC} -ne 0 ];&lt;BR /&gt;then&lt;BR /&gt;echo "Ping to ${SERVER} failed!" &amp;gt;&amp;gt; ${MSG_FILE}&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;if [ -f ${MSG_FILE} ];&lt;BR /&gt;then&lt;BR /&gt;  mailx -s "Ping failures" ${EMAIL_LIST} &amp;lt; ${MSG_FILE}&lt;BR /&gt;  rm ${MSG_FILE}&lt;BR /&gt;fi</description>
      <pubDate>Tue, 13 Dec 2005 10:36:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting/m-p/3689975#M794982</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2005-12-13T10:36:50Z</dc:date>
    </item>
  </channel>
</rss>

