Re: Output of the script.. (235 Views)
Super Advisor
Posts: 1,207
Registered: ‎05-22-2005
Message 1 of 4 (235 Views)
Accepted Solution

Output of the script..


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 ?

Trusted Contributor
Posts: 306
Registered: ‎09-15-2005
Message 2 of 4 (235 Views)

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


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

Acclaimed Contributor
Posts: 21,184
Registered: ‎07-06-2000
Message 3 of 4 (235 Views)

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.


Acclaimed Contributor
Posts: 25,896
Registered: ‎03-06-2006
Message 4 of 4 (235 Views)

Re: Output of the script..


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
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.