Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for 
Search instead for 
Did you mean: 

Output of the script..

SOLVED
Go to solution
Shivkumar
Super Advisor

Output of the script..

Hi,

I am trying to understand the output of the below shell script line.

Test2=$(/usr/ucb/ps -xuww | sed -n '/[w]eblogic.Server/ s/.*weblogic.Name=\([^ ]*\) .*/\1/p')

I am running script in debug mode but not seeing any values in the field Test2 during execution.

Can someone explain me the above script snippet in detail ?

Thanks,
Shiv
3 REPLIES
Mark McDonald_2
Trusted Contributor

Re: Output of the script..

Have you tried running all the parts on their own - to see what is happening?

eg what do these give you:

/usr/ucb/ps -xuww

AND

/usr/ucb/ps -xuww | sed -n '/[w]eblogic.Server/ s/.*weblogic.Name=\([^ ]*\) .*/\1/p'

James R. Ferguson
Acclaimed Contributor
Solution

Re: Output of the script..

Hi Shiv:

Well this isn't HP-UX (it looks like Solaris) but that aside your description says that there was nothing returned from the output after 'sed' was run.

The 'sed' looks for lines with "weblogic.Server". If found, the string following "weblogic.Name=" is captured (because of the encapsulating parentheses) and substituted (the '\1' expression without any blanks matched (the [^ ] portion.

Regards!

...JRF...
Highlighted
Dennis Handly
Acclaimed Contributor

Re: Output of the script..

>/[w]eblogic.Server/

This use of "[w]" for "w" is a standard trick so that the sed or grep doesn't find itself:
ps -ef | grep foo
This will find the process foo and the grep of foo (and any other uses of foo).
A better trick is to use not use grep:
UNIX95=EXTENDED_PS ps -f -C foo