<?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 issue. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-issue/m-p/3167976#M896891</link>
    <description>Hi Gulam,&lt;BR /&gt;&lt;BR /&gt;Try "&amp;gt;&amp;gt;" instead of  "&amp;gt;" in the third line.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
    <pubDate>Mon, 19 Jan 2004 15:36:01 GMT</pubDate>
    <dc:creator>Sridhar Bhaskarla</dc:creator>
    <dc:date>2004-01-19T15:36:01Z</dc:date>
    <item>
      <title>Shell Script issue.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-issue/m-p/3167975#M896890</link>
      <description>I am trying to search hostname from a error file and writing it into the log.out file but some how this script doesnâ  t write anything to log.out file, it just stays empty.&lt;BR /&gt;&lt;BR /&gt;for varname in $(cat /opt/omni/lbin/hosts.lst)&lt;BR /&gt;   do&lt;BR /&gt;    grep -i $varname /tmp/fail.out &amp;gt; log.out&lt;BR /&gt;   done&lt;BR /&gt;&lt;BR /&gt;Thank</description>
      <pubDate>Mon, 19 Jan 2004 15:30:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-issue/m-p/3167975#M896890</guid>
      <dc:creator>Gulam Mohiuddin</dc:creator>
      <dc:date>2004-01-19T15:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script issue.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-issue/m-p/3167976#M896891</link>
      <description>Hi Gulam,&lt;BR /&gt;&lt;BR /&gt;Try "&amp;gt;&amp;gt;" instead of  "&amp;gt;" in the third line.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Mon, 19 Jan 2004 15:36:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-issue/m-p/3167976#M896891</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-01-19T15:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script issue.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-issue/m-p/3167977#M896892</link>
      <description>try:&lt;BR /&gt;&lt;BR /&gt;cat /opt/omni/lbin/hosts.lst | while read varname&lt;BR /&gt;do&lt;BR /&gt;grep -i $varname /tmp/fail.out &amp;gt;&amp;gt; log.out&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Peter</description>
      <pubDate>Mon, 19 Jan 2004 15:36:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-issue/m-p/3167977#M896892</guid>
      <dc:creator>Hoefnix</dc:creator>
      <dc:date>2004-01-19T15:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script issue.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-issue/m-p/3167978#M896893</link>
      <description>Your problem is that you are over-writing the output file so the last one wins. If the last ${varname} doesn't produce output then you get a null file.&lt;BR /&gt;&lt;BR /&gt;rm -f log.out&lt;BR /&gt;for varname in $(cat /opt/omni/lbin/hosts.lst)&lt;BR /&gt;do&lt;BR /&gt;grep -i "${varname}" /tmp/fail.out &amp;gt;&amp;gt; log.out&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;That should fix you.</description>
      <pubDate>Mon, 19 Jan 2004 15:37:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-issue/m-p/3167978#M896893</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-01-19T15:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script issue.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-issue/m-p/3167979#M896894</link>
      <description>Run the script in debug mode to see what is actually happening:&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;set -x&lt;BR /&gt;for varname in $(cat /opt/omni/lbin/hosts.lst)&lt;BR /&gt;do&lt;BR /&gt;grep -i $varname /tmp/fail.out &amp;gt; log.out&lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt;Or you can run the script using this syntax:&lt;BR /&gt; &lt;BR /&gt;sh -x your_script&lt;BR /&gt; &lt;BR /&gt;If the list of hosts is very long, use more to slow it down and 2&amp;gt;&amp;amp;1 to re-route the trace information to stdout:&lt;BR /&gt; &lt;BR /&gt;sh -x your_script 2&amp;gt;&amp;amp;2 | more</description>
      <pubDate>Mon, 19 Jan 2004 15:38:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-issue/m-p/3167979#M896894</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2004-01-19T15:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script issue.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-issue/m-p/3167980#M896895</link>
      <description>The way you have this running, it will always echo something to the log.out file, even if it is a null when the grep doesn't match anything.&lt;BR /&gt;&lt;BR /&gt;I would consider something like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;rm log.out&lt;BR /&gt;&lt;BR /&gt;for varname in $(cat /opt/omni/lbin/hosts.lst)&lt;BR /&gt;do&lt;BR /&gt;HOST=$(grep -i ${varname} /tmp/fail.out)&lt;BR /&gt;if [[ ${HOST} != "" ]] ; then&lt;BR /&gt;echo $HOST &amp;gt;&amp;gt; log.out&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;The above will do the grep and assign the result to HOST.  Then if $HOST is NOT EMPTY it will write the value to log.out.  Note the &amp;gt;&amp;gt; in the echo.  That will append to the log.out file so that you get all possible results.  If you still want to use your own script you can replace your &amp;gt; with &amp;gt;&amp;gt; but your log.out file may have some blank lines it when the grep doesn't return anything.</description>
      <pubDate>Mon, 19 Jan 2004 15:41:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-issue/m-p/3167980#M896895</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2004-01-19T15:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script issue.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-issue/m-p/3167981#M896896</link>
      <description>By the way one can also write:&lt;BR /&gt;....&lt;BR /&gt;done &amp;gt; log.out&lt;BR /&gt;(or done &amp;gt;&amp;gt; log.out).&lt;BR /&gt;This is especially interesting if there is more than 1 command in the for-loop.&lt;BR /&gt;&lt;BR /&gt;JP</description>
      <pubDate>Tue, 20 Jan 2004 01:48:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-issue/m-p/3167981#M896896</guid>
      <dc:creator>Jeroen Peereboom</dc:creator>
      <dc:date>2004-01-20T01:48:20Z</dc:date>
    </item>
  </channel>
</rss>

