<?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 Usage error within script with grep/egrep in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935322#M102457</link>
    <description>Hello all,&lt;BR /&gt;&lt;BR /&gt;I have what hopefully will be an easy fix but I haven't been able to resolve the problem yet.  I have the following line in a script that gives a usage error when runnning with set -x:&lt;BR /&gt;&lt;BR /&gt;ABORTED_OBJECTS=`omnirpt -report session_objects -session $SESSIONS|egrep -i 'FileSystem|RawDisk'|grep $HOST_NAME|wc -l`&lt;BR /&gt;&lt;BR /&gt;I can run this omnirpt command from the command line without issue but the script shows a usage error.  Any insight would be greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Eric</description>
    <pubDate>Thu, 20 Oct 2005 11:54:36 GMT</pubDate>
    <dc:creator>erics_1</dc:creator>
    <dc:date>2005-10-20T11:54:36Z</dc:date>
    <item>
      <title>Usage error within script with grep/egrep</title>
      <link>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935322#M102457</link>
      <description>Hello all,&lt;BR /&gt;&lt;BR /&gt;I have what hopefully will be an easy fix but I haven't been able to resolve the problem yet.  I have the following line in a script that gives a usage error when runnning with set -x:&lt;BR /&gt;&lt;BR /&gt;ABORTED_OBJECTS=`omnirpt -report session_objects -session $SESSIONS|egrep -i 'FileSystem|RawDisk'|grep $HOST_NAME|wc -l`&lt;BR /&gt;&lt;BR /&gt;I can run this omnirpt command from the command line without issue but the script shows a usage error.  Any insight would be greatly appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Eric</description>
      <pubDate>Thu, 20 Oct 2005 11:54:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935322#M102457</guid>
      <dc:creator>erics_1</dc:creator>
      <dc:date>2005-10-20T11:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Usage error within script with grep/egrep</title>
      <link>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935323#M102458</link>
      <description>A bit more clarification....&lt;BR /&gt;&lt;BR /&gt;The usage error comes from egrep.  Here's the output from replacing egrep with grep -E:&lt;BR /&gt;&lt;BR /&gt;+ grep -e FileSystem -e RawDisk&lt;BR /&gt;+ wc -l&lt;BR /&gt;+ grep&lt;BR /&gt;usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] -e pattern_list...&lt;BR /&gt;        [-f pattern_file...] [file...]&lt;BR /&gt;usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] [-e pattern_list...]&lt;BR /&gt;        -f pattern_file... [file...]&lt;BR /&gt;usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] pattern [file...]&lt;BR /&gt;ABORTED_OBJECTS=0&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Eric</description>
      <pubDate>Thu, 20 Oct 2005 12:22:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935323#M102458</guid>
      <dc:creator>erics_1</dc:creator>
      <dc:date>2005-10-20T12:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Usage error within script with grep/egrep</title>
      <link>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935324#M102459</link>
      <description>Howdy Eric,&lt;BR /&gt;&lt;BR /&gt;Is the usage error from omnirpt or one of the greps?&lt;BR /&gt;&lt;BR /&gt;check that SESSIONS and HOST_NAME variables aren't null.&lt;BR /&gt;&lt;BR /&gt;I ran a similar script on a box for testing, and it went w/ out error.&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;SESSIONS="2005/10/20-1"&lt;BR /&gt;HOST_NAME=nodename&lt;BR /&gt;&lt;BR /&gt;ABORTED_OBJECTS=`omnirpt -report session_objects -session $SESSIONS|egrep -i 'FileSystem|RawDisk'|grep $HOST_NAME|wc -l`&lt;BR /&gt;&lt;BR /&gt;echo Aborted = $ABORTED_OBJECTS&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hope this helps,&lt;BR /&gt;-denver</description>
      <pubDate>Thu, 20 Oct 2005 12:26:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935324#M102459</guid>
      <dc:creator>Denver Osborn</dc:creator>
      <dc:date>2005-10-20T12:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Usage error within script with grep/egrep</title>
      <link>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935325#M102460</link>
      <description>This is a bit simpler and replaces the deprecated construct using grave accents with $() and splits each filter onto a separate line:&lt;BR /&gt; &lt;BR /&gt;set -u&lt;BR /&gt;ABORTED_OBJECTS=$(omnirpt -report session_objects -session $SESSIONS \&lt;BR /&gt;| grep -i -e FileSystem -e RawDisk \&lt;BR /&gt;| grep $HOST_NAME|wc -l)&lt;BR /&gt; &lt;BR /&gt;egrep (grep -E) can be used with multiple search terms but -e is a simpler method and doesn't need quoting to protect simple terms. The set -u is always desirable to protect against spelling errors. The shell will silently replace undefined variables with a null value, whereas set -u will abort the script indicating that an undefined variable was used as an argument ($HOST_NAME not spelled right or not assigned?)</description>
      <pubDate>Thu, 20 Oct 2005 12:30:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935325#M102460</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2005-10-20T12:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: Usage error within script with grep/egrep</title>
      <link>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935326#M102461</link>
      <description>ahh...   that looks like $HOST_NAME in the 2nd grep is null.&lt;BR /&gt;&lt;BR /&gt;-denver</description>
      <pubDate>Thu, 20 Oct 2005 12:30:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935326#M102461</guid>
      <dc:creator>Denver Osborn</dc:creator>
      <dc:date>2005-10-20T12:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: Usage error within script with grep/egrep</title>
      <link>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935327#M102462</link>
      <description>Do you want the output of the command assigned to the variable?  If so, it should be like this:&lt;BR /&gt;&lt;BR /&gt;ABORTED_OBJECTS=$(omnirpt -report session_objects -session $SESSIONS|egrep -i 'FileSystem|RawDisk'|grep $HOST_NAME|wc -l)&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 20 Oct 2005 12:33:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935327#M102462</guid>
      <dc:creator>Pat Lieberg</dc:creator>
      <dc:date>2005-10-20T12:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Usage error within script with grep/egrep</title>
      <link>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935328#M102463</link>
      <description>If the variable exists but is empty you would get such message&lt;BR /&gt;May be you could put the command into a vaiable and display it before you try to evaluate it :&lt;BR /&gt;cmd="omnirpt -report session_objects -session $SESSIONS|egrep -i 'FileSystem|RawDisk'|grep $HOST_NAME|wc -l"&lt;BR /&gt;echo $cmd&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Jean-Luc</description>
      <pubDate>Thu, 20 Oct 2005 12:34:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935328#M102463</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2005-10-20T12:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: Usage error within script with grep/egrep</title>
      <link>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935329#M102464</link>
      <description>Good call Denver,&lt;BR /&gt;&lt;BR /&gt;This script had been in place for some time.  Due to the addition of some rawdisk backups, it had to be modified.  Sometimes you get convinced where the problem lies and that's where you waste a lot of time.  HOST_NAME hadn't been set yet which I believe will fix the usage errors.  Thanks to all for your replies and time!&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Eric</description>
      <pubDate>Thu, 20 Oct 2005 12:36:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935329#M102464</guid>
      <dc:creator>erics_1</dc:creator>
      <dc:date>2005-10-20T12:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: Usage error within script with grep/egrep</title>
      <link>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935330#M102465</link>
      <description>See above</description>
      <pubDate>Thu, 20 Oct 2005 12:37:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/usage-error-within-script-with-grep-egrep/m-p/4935330#M102465</guid>
      <dc:creator>erics_1</dc:creator>
      <dc:date>2005-10-20T12:37:45Z</dc:date>
    </item>
  </channel>
</rss>

