Operating System - Linux
1753434 Members
4694 Online
108793 Solutions
New Discussion юеВ

Regarding bdf output shell script

 
Srinivas Vandanapu
New Member

Regarding bdf output shell script

I want script for, to print output of bdf and ps -e|grep name

Currently I am running bdf and check process status at regular intervals of time, this is difficult. For this i need a shell programming in a such a way that when i run the script it should print output for bdf and process status.

I am very much new to HP UNIX so pls kindly help in this regard.

4 REPLIES 4
Oviwan
Honored Contributor

Re: Regarding bdf output shell script

hey

you can do it with a loop and a sleep time:

a simple example:

#!/usr/bin/ksh
while true ; do
bdf
sleep 5
done

Regards
Dennis Handly
Acclaimed Contributor

Re: Regarding bdf output shell script

As in Oviwan's example, you can also have ps(1):
while true; do
    bdf
    UNIX95=EXTENDED_PS ps -ef -C name
    sleep 5
done

If there is a particular filesystem you want to monitor with bdf, you can add that to the above bdf command.

James R. Ferguson
Acclaimed Contributor

Re: Regarding bdf output shell script

Hi:

In the 'ps' syntax give by Dennis, he showed the syntax for all processes (and lots of information about each ('-ef') along with the syntax to select ONE process by NAME.

If you want to list all processes, simply do:

# ps -ef

If you want to select a process by NAME, don't 'grep' the process list and risk false matches. Rather use the XPG4 (known as 'UNIX95') mode:

# UNIX95= ps -C syslogd

Notice carefully that there is simply whitespace after UNIX95= and no colon! This sets UNIX95 only for the duration of the command line so that it does not impact the behavior of other commands.

When running 'ps' with UNIX95 set, you have the ability to create custom output, like:

# UNIX95= ps -C syslogd -o args -o etime

...to show the 'syslogd' process arguments and elapsed time.

If you run the above, headings for each column of data are supplied. You can suppress these with "=" characters after the option names:

# UNIX95= ps -C syslogd -o args= -o etime=

Have a look at the 'ps' manpages for more options!

Regards!

...JRF...
Hein van den Heuvel
Honored Contributor

Re: Regarding bdf output shell script

Welcome to HPUX!

The task you describe is a nice one as a reason to learn to use it well. Start with the basic scripts outlined above and improve on them

Now when you have done this for a while, please realize that the problem you are trying to solve is far from unique.
Many folks have solved similiar problems (too) many times.
There are commercial tools to do this properly as well as many 'hacks'.

Google +hpux +bdf +script +site:itrc.hp.com
And notably look for 'bdfmegs'.

You'll find stuff like:
http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1035358
http://forums12.itrc.hp.com/service/forums/questionanswer.do?94954

And the collection in:

http://forums12.itrc.hp.com/service/forums/questionanswer.do?51050

Enjoy!
Hein van den Heuvel