Languages and Scripting
Showing results for 
Search instead for 
Did you mean: 

Regarding bdf output shell script


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.

Honored Contributor

Re: Regarding bdf output shell script


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

a simple example:

while true ; do
sleep 5


Re: Regarding bdf output shell script

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

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

Acclaimed Contributor

Re: Regarding bdf output shell script


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 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!


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
And notably look for 'bdfmegs'.

You'll find stuff like:

And the collection in:

Hein van den Heuvel