1752304 Members
4796 Online
108786 Solutions
New Discussion юеВ

Re: Mr James .. UNIX95?

 
SOLVED
Go to solution
someone_4
Honored Contributor

Mr James .. UNIX95?

I posted this to an answer you gave on
http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0xcf5b46ff9277d511abcd0090277a778c,00.html

Mr. "King" James (hope you are still reading this)

I got a few questions ..
Why is the POSIX shell being referred to as
UNIX95? Why does this command not work with out the
UNIX95 variable? When I do a man on ps to see what the
-o option is it says (XPG4 Only) what does that mean and is it
related to UNIX95? Finally is there was way to sort the ps command
by cpu usage like the top command?

Thanks Richard
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor
Solution

Re: Mr James .. UNIX95?

Hi Richard:

OK, here goes.

POSIX is an acronym for "Portable Operating System Interface". It is a set of standards formulated by the IEEE, ANSI, and ISO. POSIX defines the interface between programs and operating systems.

A UNIX95 branded product is built from a number of components and includes XPG4 ("X/Open Portability Guide, Issue 4") system calls, POSIX callable interfaces, and the ISO C library among other things. HP-UX 10.20 and later are UNIX95 branded.

If you want to delve deeper, start here:

http://www.unix-systems.org/what_is_unix.html

The UNIX95 variable (when set) simply alters the way the 'ps' command functions. Setting the environmental variable arms an alternate set of options and formatting. Its setting specifies the XPG4 behavior for this command. Take look at the man pages for more details.

Lastly, yes, you could easily construct a 'ps' command, which reported CPU utilization on a process basis; pipe the output to 'sort' and produce a 'top'-like display. That's the power behind the '-o' option coupled with the quoted list of arguments. You can choose not only the elements reported, but also their order.

...with my regards!

...JRF...
A. Clay Stephenson
Acclaimed Contributor

Re: Mr James .. UNIX95?

Hi Richard,

Maybe I can help. POSIX (Portable Operating System Interface for UNIX) and XPG (X/Open POSIX GROUP) There is an XPG2,XPG3,XPG4 - all standards to make the various flavor of UNIX
more or less uniform. When UNIX95 is defined and exported XPG4 behavior is requested. This alters and augments the output and features of some commands. In the case of ps among other things it adds the -o format option.

In this case the -o "vsz" specifies virtual memory and then we sort in reverse order on the second column.

Yes you can actually modify Bill Hassell's old saw to sort by % CPU usage. I'll simply put pcpu in the same place as the original and the sort will still work.

UNIX95= ps -e -o "user,pcpu,cpu,vsz,pid,ppid,args" | sort -rnk2 . You could sort by both %cpu and vsz by altering the sort key.

Man ps & sort for more details.

Regards, Clay
If it ain't broke, I can fix that.
someone_4
Honored Contributor

Re: Mr James .. UNIX95?

WOW .. thats good stuff ..
That is allot of good usefull information.
Thanks for your great and detailed answers.


Richard