prstat in shell

Hello,

How can I do to use prstat command in a korn-shell ?

Thanks a lot.
Rgds.

Just type prstat on the command line and press enter.

If you get an error message saying something like "prstat: command not found" check your PATH environment variable to see if the directory in which prstat is located is included in the PATH

echo $PATH

Or, do you have a question about how to process the output of prstat in a specific way?

Exactly, I just want to launch prstat and use the output inside a shell.

If you check the manual page for prstat you will see that besided a lot of options there are 2 optional arguments for prstat.

These arguments are:
interval (interval in seconds between 2 statistics reports)
count (Number of statistics reports)

So you could use:

prstat 2 5
Make 5 statistics reports with an interval of 2 seconds

prtstat 3
Make endless statistics report with an interval of 3 seconds.

prstat 0 1
Make 1 statistics report with an interval of 0 seconds (The interval is irrelevant here and can be any number, since it's only 1 report).

To process the output of prstat in a scriipt you have to limit the number of statistics reports. Without this limitation prstat would never end and your script with never proceeed.

You can redirect the limited number of statistics reports to some kind of file which you use later on in your script as source to extract/generate/manipulate or whatever.

If you do not which to redirect the output to a file but like to process the outut right away, by piping the output to another command, it would be easiest to start with a single statistics report. Once you know how to parse that kind of information e.g. with (n)awk you count increase the number of statistics reports. But no matter what, make sure the number of statistics reports is limited, or your script will never end.

There are ways to process a continious output stream of prstat, but shell scripting is not really suited for that. Basically you would have 2 programs and are dealing with IPC (Inter Process Communication).

Very good.
It works fine !