- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Usage error within script with grep/egrep
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2005 04:54 AM
тАО10-20-2005 04:54 AM
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:
ABORTED_OBJECTS=`omnirpt -report session_objects -session $SESSIONS|egrep -i 'FileSystem|RawDisk'|grep $HOST_NAME|wc -l`
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.
Thanks,
Eric
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2005 05:22 AM
тАО10-20-2005 05:22 AM
Re: Usage error within script with grep/egrep
The usage error comes from egrep. Here's the output from replacing egrep with grep -E:
+ grep -e FileSystem -e RawDisk
+ wc -l
+ grep
usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] -e pattern_list...
[-f pattern_file...] [file...]
usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] [-e pattern_list...]
-f pattern_file... [file...]
usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] pattern [file...]
ABORTED_OBJECTS=0
Thanks,
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2005 05:26 AM
тАО10-20-2005 05:26 AM
SolutionIs the usage error from omnirpt or one of the greps?
check that SESSIONS and HOST_NAME variables aren't null.
I ran a similar script on a box for testing, and it went w/ out error.
#!/bin/sh
SESSIONS="2005/10/20-1"
HOST_NAME=nodename
ABORTED_OBJECTS=`omnirpt -report session_objects -session $SESSIONS|egrep -i 'FileSystem|RawDisk'|grep $HOST_NAME|wc -l`
echo Aborted = $ABORTED_OBJECTS
hope this helps,
-denver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2005 05:30 AM
тАО10-20-2005 05:30 AM
Re: Usage error within script with grep/egrep
set -u
ABORTED_OBJECTS=$(omnirpt -report session_objects -session $SESSIONS \
| grep -i -e FileSystem -e RawDisk \
| grep $HOST_NAME|wc -l)
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?)
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2005 05:30 AM
тАО10-20-2005 05:30 AM
Re: Usage error within script with grep/egrep
-denver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2005 05:33 AM
тАО10-20-2005 05:33 AM
Re: Usage error within script with grep/egrep
ABORTED_OBJECTS=$(omnirpt -report session_objects -session $SESSIONS|egrep -i 'FileSystem|RawDisk'|grep $HOST_NAME|wc -l)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2005 05:34 AM
тАО10-20-2005 05:34 AM
Re: Usage error within script with grep/egrep
May be you could put the command into a vaiable and display it before you try to evaluate it :
cmd="omnirpt -report session_objects -session $SESSIONS|egrep -i 'FileSystem|RawDisk'|grep $HOST_NAME|wc -l"
echo $cmd
Regards
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2005 05:36 AM
тАО10-20-2005 05:36 AM
Re: Usage error within script with grep/egrep
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!
Best Regards,
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2005 05:37 AM
тАО10-20-2005 05:37 AM