The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
prstat output senabhi SUN Solaris 5 05-14-2009 07:39 AM
prstat problem vivsiv Shell Programming and Scripting 6 02-15-2008 07:58 PM
stop Prstat using shell script filthymonk Shell Programming and Scripting 19 05-23-2007 05:24 AM
Mem analyze / vmstat, prstat ... unclefab SUN Solaris 2 01-24-2007 02:58 PM
Help with prstat vibhor_agarwali UNIX for Dummies Questions & Answers 6 04-07-2005 08:01 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-06-2007
madmat madmat is offline
Registered User
  
 

Join Date: Aug 2005
Location: Paris
Posts: 78
prstat in shell

Hello,

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

Thanks a lot.
Rgds.
  #2 (permalink)  
Old 02-06-2007
sb008 sb008 is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 384
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?
  #3 (permalink)  
Old 02-06-2007
madmat madmat is offline
Registered User
  
 

Join Date: Aug 2005
Location: Paris
Posts: 78
Exactly, I just want to launch prstat and use the output inside a shell.
  #4 (permalink)  
Old 02-06-2007
sb008 sb008 is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 384
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).
  #5 (permalink)  
Old 02-07-2007
madmat madmat is offline
Registered User
  
 

Join Date: Aug 2005
Location: Paris
Posts: 78
Very good.
It works fine !
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0