- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- grep command acts stupid
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
Forums
Discussions
Discussions
Discussions
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
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
01-29-2005 09:33 PM
01-29-2005 09:33 PM
grep command acts stupid
does any one have any idea why grep fails to honour any options assigned to it, say like
ps -eaf | grep -i armserver | grep -v grep
should display all lines matching with armserver but not catch grep itself, but the command fails sating -v is unknow option. similarly I have probems when I specific mutiple strings using -e option.
can any one tell me why some commands act so strange.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2005 09:42 PM
01-29-2005 09:42 PM
Re: grep command acts stupid
which grep
Also check you don't have an alias set for it by listing all your aliases:
alias
HTH
Duncan
I am an HPE Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2005 12:38 AM
01-30-2005 12:38 AM
Re: grep command acts stupid
As for the original problem, searching for a ps line without finding the searcher, I like to use a very simple regular expression instead of the target string.
For example grep for "armserve[r]" instead of armserver. This will no long match the grep command itself.
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2005 09:38 PM
01-30-2005 09:38 PM
Re: grep command acts stupid
Thanks for your reply,
I am using /usr/bin/grep itself, and problem seems to occur when it is been called from within a script.
I alos tried using the UNIX95 option, still it does sometimes does the same act.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2005 10:01 PM
01-30-2005 10:01 PM
Re: grep command acts stupid
if the problem only occures inside the script, try the which grep within the script, as you may be changing PATH.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2005 10:09 PM
01-30-2005 10:09 PM
Re: grep command acts stupid
inside the scrip has variabe defined for grep like
GREP=/usr/bin/grep
so there is issue of PATH settings.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2005 10:41 PM
01-30-2005 10:41 PM
Re: grep command acts stupid
In side the script I have a variable defined for all tools used
like
GREP=/usr/bin/grep
AWK=/usr/bin/awk
so when executing the script there is not path problems to encounterd.
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2005 10:56 PM
01-30-2005 10:56 PM
Re: grep command acts stupid
what `which grep`
and a
what /usr/bin/grep
example:
[root@vpart3 /opt/appl]# what `which grep`
/usr/bin/grep:
$Revision: B.11.11_LR
Fri Oct 27 00:57:38 PDT 2000 $
[root@vpart3 /opt/appl]#
Is this by chance a 10.20 or less HP-ux??
Or is this a sun box??
Does the error look like this when you use the "-e" option?
[root@pbsbcp /]# ps -ef | grep -e root
grep: illegal option -- e
Usage: grep -hblcnsviw pattern file . . .
[root@pbsbcp /]#
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2005 11:02 PM
01-30-2005 11:02 PM
Re: grep command acts stupid
Thanks harry for u reply,
this is a HP 9000/800/L2000 running 11i v1 with Gold Base June 2004 and another with Dec 2004 patch. yes the probem occurs usally when used with -e switch.
well I have the same script dito working in some other 11i boxes as well was linux and sun boxes. it works fine every where.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2005 11:04 PM
01-30-2005 11:04 PM
Re: grep command acts stupid
what `which grep`
and
what /usr/bin/grep
return??
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2005 01:12 AM
01-31-2005 01:12 AM
Re: grep command acts stupid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2005 02:18 AM
01-31-2005 02:18 AM
Re: grep command acts stupid
GREP=/usr/bin/grep
does that mean in your script you are doing-
ps -eaf | $GREP -i armserver | $GREP -v grep
If you are not, then the GREP= line isn't doing anything. If you are assuming it identfies where the command is, you are mistaken. The variable "PATH" defines where commands are looked for.
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2005 05:09 PM
01-31-2005 05:09 PM
Re: grep command acts stupid
Thanks for all your help,
yes the script goes like
GREP=/usr/bin/grep
ps -eaf | $GREP -i armserver | $GREP -v grep
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2005 06:16 PM
01-31-2005 06:16 PM
Re: grep command acts stupid
-e expects a pattern and has to come after -v. Do you use it that way?
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2005 07:22 PM
01-31-2005 07:22 PM
Re: grep command acts stupid
here is the line as it is in the script
GREP=/usr/bin/grep
set -x
ps -eaf | $GREP -i -e armserver -e arraymod | grep -v grep
set +x
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2005 07:24 PM
01-31-2005 07:24 PM
Re: grep command acts stupid
the output of what command is
# what `which grep`
/usr/bin/grep:
$Revision: B.11.11_LR
Fri Oct 27 00:57:38 PDT 2000 $
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2005 11:17 PM
01-31-2005 11:17 PM
Re: grep command acts stupid
>GREP=/usr/bin/grep
>set -x
>ps -eaf | $GREP -i -e armserver -e arraymod | grep -v grep
>set +x
Two comments on this:
Firstly, you're using $GREP for one call, and just 'grep' for the other, not $GREP for both as suggested in an earlier response. As others have suggested, we'd need to see the path for 'grep' within the script.
Secondly, what is the output when you run this - what does the -x output show for this line?
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2005 12:09 AM
02-01-2005 12:09 AM
Re: grep command acts stupid
Try this at the COMMAND LINE:
GREP=/usr/bin/grep
ps -eaf | ${GREP} -i -e armserver -e arraymod | ${GREP} -v grep
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2005 12:11 AM
02-01-2005 12:11 AM
Re: grep command acts stupid
you stated in an earlier post that you tried using the UNIX95 option. Can you confirm that UNIX95 is not set in you script? I have the idea that setting this variable may - in connection with executing ps - cause some disturbance as to what may be considered options to the ps command(!).
Just an idea, but try inserting:
unset UNIX95
just before the grep command.
regards,
John K,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2005 01:40 AM
02-01-2005 01:40 AM
Re: grep command acts stupid
UNIX95 influences ps but I found not reference to an influence in grep.
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2005 01:46 AM
02-01-2005 01:46 AM
Re: grep command acts stupid
UNIX95= ps -fC armserver
UNIX95 turns on additional options in grep, -C being the most useful. ps -e is very intrusive on a busy system which is why it's best to let ps (and not grep) look for the processes by name. You can use multiple -C options just like -e in grep:
UNIX95= ps -f -C armserver -C arraymond
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2005 02:13 AM
02-01-2005 02:13 AM
Re: grep command acts stupid
Michael, I did not dare to directly present the perhaps crazy idea that $GREP might somehow in this context be considered an option to the ps command.
Maybe I will now.....
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2005 03:43 PM
02-01-2005 03:43 PM
Re: grep command acts stupid
Thank you all for your inputs and support,
I think I will stick with UNIX95 option and use Bill's option of using -C with ps, I have replaced the lines and works fine in all patforms. So I am going to let grep as it is and closing this thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2005 03:44 PM
02-01-2005 03:44 PM
Re: grep command acts stupid
thread closed