<?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: awk to run execute within a script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042956#M95880</link>
    <description>Hi Lawrenzo,&lt;BR /&gt;&lt;BR /&gt;Why not use grep's 'quiet' option, as all you're really interested in is the return code?&lt;BR /&gt;&lt;BR /&gt;echo ${PROGMSG} | grep -q 'Connection refused'&lt;BR /&gt;RC=${?}&lt;BR /&gt;if [ "${RC}" -ne "0" ]&lt;BR /&gt;then&lt;BR /&gt;    echo "Exiting with rc ${RC}"&lt;BR /&gt;    exit ${RC}&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;If you're looking to kill the parent shell script from within awk, this should work:&lt;BR /&gt;&lt;BR /&gt;awk '/Connection refused/ {system("kill $PPID")}'&lt;BR /&gt;&lt;BR /&gt;This yields an exit status of '143' on my system.&lt;BR /&gt;&lt;BR /&gt;PCS</description>
    <pubDate>Fri, 27 Apr 2007 13:57:37 GMT</pubDate>
    <dc:creator>spex</dc:creator>
    <dc:date>2007-04-27T13:57:37Z</dc:date>
    <item>
      <title>awk to run execute within a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042951#M95875</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have setup some simple code but would like to know if there is an awk alternative that if the string "Connection refused" is in $PROGMESG then exit the script.&lt;BR /&gt;&lt;BR /&gt;NOSEND=`echo $PROGMSG |awk '/Connection refused/ {print}'`&lt;BR /&gt;&lt;BR /&gt;        if [ $NOSEND = "Connection refused" ] ; then&lt;BR /&gt;&lt;BR /&gt;                exit 1&lt;BR /&gt;&lt;BR /&gt;        fi&lt;BR /&gt;&lt;BR /&gt;thanks</description>
      <pubDate>Fri, 27 Apr 2007 13:29:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042951#M95875</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2007-04-27T13:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: awk to run execute within a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042952#M95876</link>
      <description>sorry I should give this example:&lt;BR /&gt;&lt;BR /&gt;NOSEND=`echo $PROGMSG |grep -c "Connection refused"'`&lt;BR /&gt;&lt;BR /&gt;        if [[ $NOSEND -gt 0 ]] ; then&lt;BR /&gt;&lt;BR /&gt;                exit 1&lt;BR /&gt;&lt;BR /&gt;        fi&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Apr 2007 13:41:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042952#M95876</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2007-04-27T13:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: awk to run execute within a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042953#M95877</link>
      <description># echo $PROGMSG | awk '$0=="Connection refused" &amp;amp;&amp;amp; exit</description>
      <pubDate>Fri, 27 Apr 2007 13:44:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042953#M95877</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-04-27T13:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: awk to run execute within a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042954#M95878</link>
      <description>here another one&lt;BR /&gt;&lt;BR /&gt;echo $PROGMSG | grep "Connection Refused"&lt;BR /&gt;NOSEND=?*&lt;BR /&gt;&lt;BR /&gt;if [ $NOSEND -eq 0 ]; then&lt;BR /&gt;&lt;BR /&gt;    exit 1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Apr 2007 13:48:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042954#M95878</guid>
      <dc:creator>OldSchool</dc:creator>
      <dc:date>2007-04-27T13:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: awk to run execute within a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042955#M95879</link>
      <description>Update as I omitted the awk-action stmt.&lt;BR /&gt;&lt;BR /&gt;# echo $PROGMSG | awk '$0=="Connection refused"{}' &amp;amp;&amp;amp; exit</description>
      <pubDate>Fri, 27 Apr 2007 13:48:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042955#M95879</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-04-27T13:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: awk to run execute within a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042956#M95880</link>
      <description>Hi Lawrenzo,&lt;BR /&gt;&lt;BR /&gt;Why not use grep's 'quiet' option, as all you're really interested in is the return code?&lt;BR /&gt;&lt;BR /&gt;echo ${PROGMSG} | grep -q 'Connection refused'&lt;BR /&gt;RC=${?}&lt;BR /&gt;if [ "${RC}" -ne "0" ]&lt;BR /&gt;then&lt;BR /&gt;    echo "Exiting with rc ${RC}"&lt;BR /&gt;    exit ${RC}&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;If you're looking to kill the parent shell script from within awk, this should work:&lt;BR /&gt;&lt;BR /&gt;awk '/Connection refused/ {system("kill $PPID")}'&lt;BR /&gt;&lt;BR /&gt;This yields an exit status of '143' on my system.&lt;BR /&gt;&lt;BR /&gt;PCS</description>
      <pubDate>Fri, 27 Apr 2007 13:57:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042956#M95880</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2007-04-27T13:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: awk to run execute within a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042957#M95881</link>
      <description>- Why use an intermediary symbol? Just use the exit status!&lt;BR /&gt;&lt;BR /&gt;- Why count? Just tell grep to quit on first match.&lt;BR /&gt;&lt;BR /&gt;if $(echo $PROGMSG | grep -q "Connection refused"); &lt;BR /&gt;then&lt;BR /&gt;echo aap&lt;BR /&gt;else&lt;BR /&gt;echo noot&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Apr 2007 14:00:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042957#M95881</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-04-27T14:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: awk to run execute within a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042958#M95882</link>
      <description>And the shell itself can of course do string pattern matching and testing avoiding the extra processess:&lt;BR /&gt;&lt;BR /&gt;$ PROGMSG="Connection refused"&lt;BR /&gt;$ if [[ $PROGMSG = "Connection refused" ]]; then&lt;BR /&gt;echo aap&lt;BR /&gt;else&lt;BR /&gt;echo noor&lt;BR /&gt;fi&lt;BR /&gt;aap&lt;BR /&gt;&lt;BR /&gt;This is often best done for a positive match, such that various and new error message are also caught as needed.&lt;BR /&gt;&lt;BR /&gt;Hein&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Apr 2007 14:28:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042958#M95882</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-04-27T14:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: awk to run execute within a script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042959#M95883</link>
      <description>ok thanks guys - lotsw of examples there ...</description>
      <pubDate>Tue, 01 May 2007 02:32:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/awk-to-run-execute-within-a-script/m-p/5042959#M95883</guid>
      <dc:creator>lawrenzo_1</dc:creator>
      <dc:date>2007-05-01T02:32:00Z</dc:date>
    </item>
  </channel>
</rss>

