<?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: Script Needed in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688621#M640754</link>
    <description>This is what I had done before - &lt;BR /&gt;&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;&lt;BR /&gt;CONFFILE=/tmp/url1ist&lt;BR /&gt;&lt;BR /&gt;read URL &amp;lt; "$CONFFILE"&lt;BR /&gt;&lt;BR /&gt;echo "Fetching $URL..."&lt;BR /&gt;curl "$URL"&lt;BR /&gt;&lt;BR /&gt;case "$?" in&lt;BR /&gt;0)&lt;BR /&gt;    echo "Service is ok"&lt;BR /&gt;    exit 0&lt;BR /&gt;    ;;&lt;BR /&gt;1)&lt;BR /&gt;    echo "WARN"&lt;BR /&gt;    exit 1&lt;BR /&gt;    ;;&lt;BR /&gt;2)&lt;BR /&gt;    echo "ERROR OR FATAL"&lt;BR /&gt;    exit 2&lt;BR /&gt;    ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Sat, 09 Apr 2011 04:36:00 GMT</pubDate>
    <dc:creator>Allanm</dc:creator>
    <dc:date>2011-04-09T04:36:00Z</dc:date>
    <item>
      <title>Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688617#M640750</link>
      <description>Hi!&lt;BR /&gt;&lt;BR /&gt;I have a file which has the following entry - &lt;BR /&gt;&lt;BR /&gt;NSRService&lt;BR /&gt;&lt;A href="http://someurl.com:port1/...." target="_blank"&gt;http://someurl.com:port1/....&lt;/A&gt;&lt;BR /&gt;TSRService&lt;BR /&gt;&lt;A href="http://someurl2.com:port2/..." target="_blank"&gt;http://someurl2.com:port2/...&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;which has different service names with their corresponding URLs.&lt;BR /&gt;&lt;BR /&gt;I want to echo the servicenames and curl each URL and find out if the URL is accessible or not.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Allan.</description>
      <pubDate>Mon, 20 Sep 2010 07:23:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688617#M640750</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2010-09-20T07:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688618#M640751</link>
      <description>Something like this?&lt;BR /&gt;&lt;BR /&gt;---------------------------&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;RESULT=0&lt;BR /&gt;&lt;BR /&gt;# read all input from the specified file&lt;BR /&gt;exec &amp;lt;"$1" &lt;BR /&gt;&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;    read SERVICE&lt;BR /&gt;    if [ "$SERVICE" = "" ]&lt;BR /&gt;    then&lt;BR /&gt;        # no more services&lt;BR /&gt;        exit $RESULT&lt;BR /&gt;    fi&lt;BR /&gt;&lt;BR /&gt;    read URL&lt;BR /&gt;    if [ "$URL" = "" ]&lt;BR /&gt;    then&lt;BR /&gt;        # error in service list file&lt;BR /&gt;        echo "ERROR: no URL for service $SERVICE" &amp;gt;&amp;amp;2&lt;BR /&gt;        exit 2&lt;BR /&gt;    fi&lt;BR /&gt;&lt;BR /&gt;    echo "Testing $SERVICE: "&lt;BR /&gt;&lt;BR /&gt;    # adjust the options to suit your needs&lt;BR /&gt;    curl -I $URL&lt;BR /&gt;&lt;BR /&gt;    if [ $? -eq 0 ]&lt;BR /&gt;    then&lt;BR /&gt;        echo "Success"&lt;BR /&gt;    else&lt;BR /&gt;        echo "Fail"&lt;BR /&gt;        RESULT=1&lt;BR /&gt;    fi&lt;BR /&gt;done&lt;BR /&gt;------------------------------&lt;BR /&gt;&lt;BR /&gt;Save the script to a file, then run with e.g.&lt;BR /&gt;&lt;BR /&gt;sh scriptname.sh servicelist.txt&lt;BR /&gt;&lt;BR /&gt;NOTE: the script assumes there are no blank lines in the service list file.&lt;BR /&gt;&lt;BR /&gt;The script returns exit code 0 if all services were accessible, 1 if at least one curl command failed, and 2 if there is an error in the service list file.&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Mon, 20 Sep 2010 10:11:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688618#M640751</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2010-09-20T10:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688619#M640752</link>
      <description>Hi All, &lt;BR /&gt;&lt;BR /&gt;I am reopening this thread the curl that I run against the URL returns a response (has a text called alive in the return ), so I need to validate that I do see the text alive in the page before we say the URL is working else send an email saying that this service failed.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Allan.</description>
      <pubDate>Fri, 08 Apr 2011 23:59:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688619#M640752</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2011-04-08T23:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688620#M640753</link>
      <description>&lt;!--!*#--&gt;      man grep&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Script Needed&lt;BR /&gt;&lt;BR /&gt;Are you asking for help in writing a script,&lt;BR /&gt;or do you simply want someone else to do your&lt;BR /&gt;whole job for you?  What have _you_ done?</description>
      <pubDate>Sat, 09 Apr 2011 01:28:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688620#M640753</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2011-04-09T01:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688621#M640754</link>
      <description>This is what I had done before - &lt;BR /&gt;&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;&lt;BR /&gt;CONFFILE=/tmp/url1ist&lt;BR /&gt;&lt;BR /&gt;read URL &amp;lt; "$CONFFILE"&lt;BR /&gt;&lt;BR /&gt;echo "Fetching $URL..."&lt;BR /&gt;curl "$URL"&lt;BR /&gt;&lt;BR /&gt;case "$?" in&lt;BR /&gt;0)&lt;BR /&gt;    echo "Service is ok"&lt;BR /&gt;    exit 0&lt;BR /&gt;    ;;&lt;BR /&gt;1)&lt;BR /&gt;    echo "WARN"&lt;BR /&gt;    exit 1&lt;BR /&gt;    ;;&lt;BR /&gt;2)&lt;BR /&gt;    echo "ERROR OR FATAL"&lt;BR /&gt;    exit 2&lt;BR /&gt;    ;;&lt;BR /&gt;esac&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 09 Apr 2011 04:36:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688621#M640754</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2011-04-09T04:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688622#M640755</link>
      <description>&lt;!--!*#--&gt;&amp;gt; #!/bin/bash&lt;BR /&gt;&lt;BR /&gt;Why not something simple, like, say,&lt;BR /&gt;"/bin/sh" (which is available everywhere)?&lt;BR /&gt;Are you using exotic bash-only features?&lt;BR /&gt;&lt;BR /&gt;&amp;gt; curl "$URL"&lt;BR /&gt;&lt;BR /&gt;If you send the output to a file, ...&lt;BR /&gt;&lt;BR /&gt;      curl "$URL" &amp;gt; out_file&lt;BR /&gt;or:&lt;BR /&gt;      curl -o out_file "$URL"&lt;BR /&gt;&lt;BR /&gt;then you could look at the exit status from&lt;BR /&gt;a command like, say:&lt;BR /&gt;&lt;BR /&gt;      grep alive out_file&lt;BR /&gt;or:&lt;BR /&gt;      grep alive out_file &amp;gt; /dev/null&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;      man grep&lt;BR /&gt;      curl -h&lt;BR /&gt;&lt;BR /&gt;You could also use one big pipeline:&lt;BR /&gt;&lt;BR /&gt;      curl "$URL" | grep alive [&amp;gt; /dev/null]&lt;BR /&gt;&lt;BR /&gt;but that makes it harder to look at the exit&lt;BR /&gt;status values of the individual programs (if&lt;BR /&gt;you wish to do that).  (I'd start with&lt;BR /&gt;separate commands, and, perhaps, try to&lt;BR /&gt;combine things later.)</description>
      <pubDate>Sat, 09 Apr 2011 05:48:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688622#M640755</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2011-04-09T05:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688623#M640756</link>
      <description>Thanks Steve, I really want to avoid the use of file to save data temporarily.&lt;BR /&gt;&lt;BR /&gt;I tried this as well (which works)- &lt;BR /&gt;&lt;BR /&gt;curl  -s http://URL|perl -0ne '$x=/"alive"/?"OK":"FAIL";print "$x\n"'&lt;BR /&gt;&lt;BR /&gt;But want a script in perl or shell and not a combination of the two. If I get an error then it should send me an email.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Allan.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 09 Apr 2011 19:55:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688623#M640756</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2011-04-09T19:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688624#M640757</link>
      <description>&lt;!--!*#--&gt;&amp;gt; You could also use one big pipeline:&lt;BR /&gt;&amp;gt; &lt;BR /&gt;&amp;gt;       curl "$URL" | grep alive [/dev/null]&lt;BR /&gt;&lt;BR /&gt;Still true.  Did you try that?  Doesn't "$?"&lt;BR /&gt;work with that?&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] If I get an error then it should send&lt;BR /&gt;&amp;gt; me an email.&lt;BR /&gt;&lt;BR /&gt;Is that a problem?  A Forum search for&lt;BR /&gt;keywords like, say:&lt;BR /&gt;&lt;BR /&gt;      script send e-mail mailx&lt;BR /&gt;&lt;BR /&gt;should find many examples of scripts which do&lt;BR /&gt;that.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; [...] I really want to avoid the use of&lt;BR /&gt;&amp;gt; file to save data temporarily.&lt;BR /&gt;&lt;BR /&gt;Ok, but why?  Sometimes that's the easy way.&lt;BR /&gt;Especially when one is composing an e-mail&lt;BR /&gt;message.  There are, of course, good ways and&lt;BR /&gt;bad ways to use a temporary file.  Including&lt;BR /&gt;the process ID in the file name can help to&lt;BR /&gt;avoid problems when two people try to do&lt;BR /&gt;something at the same time, for example.  As&lt;BR /&gt;usual, many things are possible:&lt;BR /&gt;&lt;BR /&gt;alp$ cat td.sh&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;TMPDIR=${TMPDIR:-/tmp}&lt;BR /&gt;base_name=` basename $0 `&lt;BR /&gt;&lt;BR /&gt;temp_file_1_name="${TMPDIR}/${base_name}_1_$$.tmp"&lt;BR /&gt;&lt;BR /&gt;echo "t_f_n_1: ${temp_file_1_name}"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;alp$ ./td.sh&lt;BR /&gt;t_f_n_1: /tmp/td.sh_1_538971991.tmp&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 09 Apr 2011 22:03:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688624#M640757</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2011-04-09T22:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688625#M640758</link>
      <description>&lt;!--!*#--&gt;One other nice thing about a temporary file&lt;BR /&gt;is that it can provide some clues when&lt;BR /&gt;something goes wrong in your script.&lt;BR /&gt;Normally, when a script creates any temporary&lt;BR /&gt;files, it would delete them before it exits.&lt;BR /&gt;If the script behaves badly, and explodes&lt;BR /&gt;before it can exit normally, then it would&lt;BR /&gt;leave its temporary files lying around, where&lt;BR /&gt;you can examine them.  Just finding an&lt;BR /&gt;unexpected temporary file tells you that&lt;BR /&gt;something went wrong.  Then, the file's&lt;BR /&gt;contents may tell you more.</description>
      <pubDate>Sat, 09 Apr 2011 23:01:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688625#M640758</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2011-04-09T23:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688626#M640759</link>
      <description>I am not very familiar with usage of curl but did you consider using wget instead ? I believe curl has the capability of form submissions or similar over wget, but if all you are interested in is to capture a string saying "alive" in the output, wget may do the job for you.&lt;BR /&gt;&lt;BR /&gt;wget $URL | grep -q -i alive; r=${?}&lt;BR /&gt;if [ ${r} -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo "System is alive : `date`" &amp;gt;&amp;gt; $MYLOGFILE #if needed&lt;BR /&gt;else&lt;BR /&gt;echo "$URL is not ALIVE" | sendmail me@mydomain.com &lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Is there something else you want, that I am missing ?&lt;BR /&gt;&lt;BR /&gt;You can go fancy and use mailx instead of sendmail but it is a choice. I chose the simple one.</description>
      <pubDate>Sun, 10 Apr 2011 00:22:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688626#M640759</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2011-04-10T00:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688627#M640760</link>
      <description>&lt;!--!*#--&gt;&amp;gt; I am not very familiar with usage of curl&lt;BR /&gt;&lt;BR /&gt;      curl -h&lt;BR /&gt;&lt;BR /&gt;&amp;gt;  but did you consider using wget instead ?&lt;BR /&gt;&lt;BR /&gt;I also normally use "wget" for this sort of&lt;BR /&gt;thing, but I doubt that it would make much of&lt;BR /&gt;a difference.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; wget $URL | grep -q -i alive; r=${?}&lt;BR /&gt;&lt;BR /&gt;On the other hand, I'd expect "wget" to save&lt;BR /&gt;its result in a file, unless I used its "-O"&lt;BR /&gt;option to persuade it to do otherwise, so I&lt;BR /&gt;wouldn't expect ever to see "alive" flowing&lt;BR /&gt;through this particular pipeline.&lt;BR /&gt;&lt;BR /&gt;How carefully did you test this suggestion?&lt;BR /&gt;&lt;BR /&gt;&amp;gt; You can go fancy and use mailx instead of&lt;BR /&gt;&amp;gt; sendmail but it is a choice. I chose the&lt;BR /&gt;&amp;gt; simple one.&lt;BR /&gt;&lt;BR /&gt;Define "simple".  I prefer an e-mail message&lt;BR /&gt;with a Subject.  "mailx" makes _that_ simple.</description>
      <pubDate>Sun, 10 Apr 2011 00:44:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688627#M640760</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2011-04-10T00:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688628#M640761</link>
      <description>Hi Allan:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; But want a script in perl or shell and not a combination of the two.&lt;BR /&gt;&lt;BR /&gt;So, Matti, Steven and Mel have already offered several variations using a shell.&lt;BR /&gt;&lt;BR /&gt;The Perl snippet :&lt;BR /&gt;&lt;BR /&gt;# curl -s http://${URL} | perl -0ne '$x=/"alive"/?"OK":"FAIL";print "$x\n"'&lt;BR /&gt;&lt;BR /&gt;...is simply reading the pipe output as one, big record.  It then simply reports the presence or absence of a string '"alive"'.&lt;BR /&gt;&lt;BR /&gt;What's wrong with using this piece of Perl in a shell script?  How is that different from saying a shell script with an 'awk' or 'grep' command to perform matching isn't a shell script?  Where you draw the line is somewhat a matter of taste.  If I had a shell script with many Perl commandline scripts embedded within, I would certainly consider re-writing it purely in Perl, but for performing the task as you have stated it, I'd do what is ever comfortable to you.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sun, 10 Apr 2011 15:23:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688628#M640761</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-04-10T15:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688629#M640762</link>
      <description>Thanks for your replies, one more thing, due to the sake of false alerting (flapping) can we build something like "4 times service failure checks with 20 seconds intervals before raise an alarm"?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Allan</description>
      <pubDate>Mon, 11 Apr 2011 14:30:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688629#M640762</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2011-04-11T14:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688630#M640763</link>
      <description>Hi (again) Allan:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; one more thing, due to the sake of false alerting (flapping) can we build something like "4 times service failure checks with 20 seconds intervals before raise an alarm"?&lt;BR /&gt;&lt;BR /&gt;Are you using Nagios?  If so, then you should be able to add this protection with relative ease.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 11 Apr 2011 14:40:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688630#M640763</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-04-11T14:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688631#M640764</link>
      <description>Hi JRF, &lt;BR /&gt;&lt;BR /&gt;This is a contingency for Nagios, as its down currently.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Allan.</description>
      <pubDate>Mon, 11 Apr 2011 15:14:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688631#M640764</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2011-04-11T15:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688632#M640765</link>
      <description>HI (again) Allan:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; This is a contingency for Nagios, as its down currently.&lt;BR /&gt;&lt;BR /&gt;I would think that Nagios would be of more importance given that is probably supports a great deal more things then just the subject of this query (?)&lt;BR /&gt;&lt;BR /&gt;A crude suggestion would be to test the viability of each URL several times with a wait (sleep) in between.  Then if there are more than some number of connection failures, per URL, consider it unavailable.  At least in this fashion, one failure would not spell doom.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 11 Apr 2011 15:23:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688632#M640765</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-04-11T15:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688633#M640766</link>
      <description>Hi JRF!&lt;BR /&gt;&lt;BR /&gt;This is as far as I have been able to go - &lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;OP=0&lt;BR /&gt;&lt;BR /&gt;exec &amp;lt;"/fs1/ainuser/ain/user-1/list"&lt;BR /&gt;&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;        read APP&lt;BR /&gt;                if [ "$APP" = "" ]&lt;BR /&gt;                then&lt;BR /&gt;                        exit $OP&lt;BR /&gt;                fi&lt;BR /&gt;&lt;BR /&gt;        read URL&lt;BR /&gt;                if [ "$URL" = "" ]&lt;BR /&gt;                then&lt;BR /&gt;                        echo "ERROR no URL defined for $APP" &amp;gt;&amp;amp;2&lt;BR /&gt;                        exit 2&lt;BR /&gt;                fi&lt;BR /&gt;        v=1   &lt;BR /&gt;        while ( $v -le 6 )&lt;BR /&gt;        do&lt;BR /&gt;        sleep 3&lt;BR /&gt;&lt;BR /&gt;        echo "Checking $APP: "&lt;BR /&gt;        curl $URL |grep -q -i alive&lt;BR /&gt;        x=$?&lt;BR /&gt;                if [ ${x} -eq 0 ]&lt;BR /&gt;                then&lt;BR /&gt;                        echo "App is alive : `date`"&lt;BR /&gt;                else&lt;BR /&gt;                        echo "$APP is down in env-1" | mail -s "$APP is down in env-1" testalert@email.com&lt;BR /&gt;                fi&lt;BR /&gt;     v=$(( $v + 1 ))&lt;BR /&gt;         done&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Now I want some help on how to go about storing the curl results and checking to see if it falied atleast 3 times before I send an alert email.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Allan</description>
      <pubDate>Mon, 11 Apr 2011 19:37:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688633#M640766</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2011-04-11T19:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688634#M640767</link>
      <description>Hi (again) Allan:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Now I want some help on how to go about storing the curl results and checking to see if it falied atleast 3 times before I send an alert email.&lt;BR /&gt;&lt;BR /&gt;You shouldn't need to store the 'curl' results.  All this is necessary is to count the number of successes of failures.  For instance, if you sample 10-times, quit after the allowed number of failures (e.g. 5) is exceeded.  At the end of either 10-samples or a failure threshold exceeded, exit the enclosing loop; test for the failures counted and send an email appropriately. &lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 11 Apr 2011 19:52:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688634#M640767</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-04-11T19:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688635#M640768</link>
      <description>I tried here , please review and modify- &lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;OP=0&lt;BR /&gt;&lt;BR /&gt;exec &amp;lt;"/fs1/ainuser/ain/user-1/list"&lt;BR /&gt;&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;        read APP&lt;BR /&gt;                if [ "$APP" = "" ]&lt;BR /&gt;                then&lt;BR /&gt;                        exit $OP&lt;BR /&gt;                fi&lt;BR /&gt;&lt;BR /&gt;        read URL&lt;BR /&gt;                if [ "$URL" = "" ]&lt;BR /&gt;                then&lt;BR /&gt;                        echo "ERROR no URL defined for $APP" &amp;gt;&amp;amp;2&lt;BR /&gt;                        exit 2&lt;BR /&gt;                fi&lt;BR /&gt;        v=1   &lt;BR /&gt;        while ( $v -le 4 )&lt;BR /&gt;        do&lt;BR /&gt;        sleep 3&lt;BR /&gt;&lt;BR /&gt;        echo "Checking $APP: "&lt;BR /&gt;        curl $URL |grep -q -i alive&lt;BR /&gt;        y=0&lt;BR /&gt;        x=$?&lt;BR /&gt;                if [ ${x} -eq 0 -a ${y} -eq 4 ]&lt;BR /&gt;                then&lt;BR /&gt;                        echo "App is alive : `date`"&lt;BR /&gt;                else&lt;BR /&gt;                        echo "$APP is down in env-1" | mail -s "$APP is down in env-1" testalert@email.com&lt;BR /&gt;                        y=$(( $y + 1 ))&lt;BR /&gt;                fi&lt;BR /&gt;     v=$(( $v + 1 ))&lt;BR /&gt;         done&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Apr 2011 20:13:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688635#M640768</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2011-04-11T20:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: Script Needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688636#M640769</link>
      <description>I have found few issues, fixing those, specially to do with the place of $? in the script.</description>
      <pubDate>Mon, 11 Apr 2011 20:27:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-needed/m-p/4688636#M640769</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2011-04-11T20:27:44Z</dc:date>
    </item>
  </channel>
</rss>

