Operating System - HP-UX
1819933 Members
3202 Online
109607 Solutions
New Discussion юеВ

Widening the column scope for ps -ef | grep call

 
chris79
New Member

Widening the column scope for ps -ef | grep call

Hi

I'm trying to grep for a string output from a ps -ef call, however since the column width of the terminal/console is 80(?) characters the grep fails to find the string because the end of the line is chopped off.
For example:
ps ef | grep $1

On other Unix/Linux platforms I can normally modify the COLUMNS environment to an arbitarily high value, say 300. The result is that the grep finds the string as it isn't "lost" off the end of the terminal.

On HP though, this doesn't work. Is there an alternative way of achieving this behaviour?

Many thanks in advance
Chris
9 REPLIES 9
Steve Steel
Honored Contributor

Re: Widening the column scope for ps -ef | grep call

Hi


Try the unix95 in ps something like this

echo memory usage per process
echo "----------------------------------------------"
UNIX95= ps -e -o stime,ruser,vsz,sz,pid,ppid,tty,args > /tmp/$PPID
head -n 1 /tmp/$PPID
tail -n +2 /tmp/$PPID|
sort -rn
/bin/rm /tmp/$PPID 2>/dev/null

Then you can get what you seek

Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Pete Randall
Outstanding Contributor

Re: Widening the column scope for ps -ef | grep call

Chris,

You might also want to look at using

ps -efx grep $1


Pete

Pete
Muthukumar_5
Honored Contributor

Re: Widening the column scope for ps -ef | grep call

You have to use ps with - first,

if you put ps ef it will give the ps command result only.

To get more extended format use as,

ps -efl | grep -v grep | grep $1

You have to use grep -v grep to avoid on getting grep process too.

or

ps -efx | grep -v grep | grep $1

It will not chomp the output anyway.

If so let us know about that by tunning COLUMNS environment variable too.
Easy to suggest when don't know about the problem!
chris79
New Member

Re: Widening the column scope for ps -ef | grep call

Thanks for the replies. However, the -x flag is not recognised with the 'ps' i'm using:

# ps -efx | grep LaunchFile
ps: illegal option -- x
usage: ps [-edaflP] [-u ulist] [-g glist] [-p plist] [-t tlist] [-R prmgroup]


Thanks

Chris
chris79
New Member

Re: Widening the column scope for ps -ef | grep call

Calling ps -efl was accepted but, athough it widened some of the columns, the final column (args?) remains at maximum length of 60 characters. This is too short for what I need.

Thanks
Chris
Pete Randall
Outstanding Contributor

Re: Widening the column scope for ps -ef | grep call

Chris,

You didn't mention what version of HP-UX you're using. I assume, since the -x option was not available to you, you must be on 11.0 or earlier. The following document details the extension for 11i:

http://www1.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000063200617

In case you can't retrieve that, I'll quote the pertinent part:

"While there is no other solution for 11.00, the option -x extends the COMMAND field to 1024 characters on 11.11"


Pete

Pete
Patrick Wallek
Honored Contributor

Re: Widening the column scope for ps -ef | grep call

There is a patch that enables the 'x' option to ps which will give you a wider/longer last column.

The latest 'ps' cumulative patch for HP-UX 11.11 is PHCO_30397
http://www1.itrc.hp.com/service/patch/patchDetail.do?BC=patch.breadcrumb.main|patch.breadcrumb.search|&patchid=PHCO_30397&context=hpux:800:11:11

The latest 'ps' cumulative patch for HP-UX 11.0 is PHCO_30559
http://www1.itrc.hp.com/service/patch/patchDetail.do?BC=patch.breadcrumb.main|patch.breadcrumb.search|&patchid=PHCO_30559&context=hpux:800:11:00

Be sure to check all of the patch dependencies as well.
chris79
New Member

Re: Widening the column scope for ps -ef | grep call

Pete

Yes, I'm running with 11.00.

Oh, well...


Many thanks for your help
Chris
Muthukumar_5
Honored Contributor

Re: Widening the column scope for ps -ef | grep call

We have to have XPG4 support to have the synapsis as,

XPG4 Synopsis
ps [-aAcdefHjlPx] [-C cmdlist] [-g grplist] [-G gidlist] [-n namelist]
[-o format] [-p proclist] [-R prmgrplist] [-s sidlist] [-t termlist]
[-u uidlist] [-U uidlist]

Here you can use that -x format too,


To do this,

set an environment variable as,

UNIX95=XPG4;export $UNIX95

Is it working out now with ps -efx there

Easy to suggest when don't know about the problem!