Operating System - HP-UX
1832976 Members
2662 Online
110048 Solutions
New Discussion

Re: Using mpsched -s in scripts

 
SOLVED
Go to solution
paul_221
Occasional Contributor

Using mpsched -s in scripts

I am using mpsched in a script to figure out the number of cpus per partition. Everytime I use mpsched -s it displays on the screen.

I am trying to use:

mpsched -s | grep -w Processor | awk '{print $4}'

But I can not capture the output because it is only displaying on the screen. Any thoughts??
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor

Re: Using mpsched -s in scripts

Hi:

If you want to capture the output into a variable (e.g. 'X') do this:

# X=`mpsched -s|grep -w Processor|awk '{print $4}'`

Regards!

...JRF...
paul_221
Occasional Contributor

Re: Using mpsched -s in scripts

If the following code is run the variable is not initialized and the results are displayed on the screen.

X=`mpsched -s|grep -w Processor|awk '{print $4}'`

Solution

Re: Using mpsched -s in scripts

Its redirecting the output to stderr not stdout.

Try

mpsched -s 2>&1 | grep -w 'Processor' | awk '{print $4}'

Adam
Don't chuck bricks at cows.