Is it possible to extract these values from the output


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 1  
Is it possible to extract these values from the output

Hi,

I would like to search based of "java" and "-Dplatform.home=" and store these two values in bash variables.

Code:
 
ps -xef | grep <pid>
     wlsuser 15160 15144  0  Feb 20  ?  17:27 /app1/jdk150_07/bin/IA64N/java -server -Xms1536m -Dplatform.home=/app1/bea/weblogic92 -Dwli.home=/app1/bea/weblogic92/integration

Desired ouput:
Code:
 
java_home=/app1/jdk150_07/bin/IA64N/java 
weblogic_home=/app1/bea/weblogic92

# 2  
I guess this has been answered in this thread

https://www.unix.com/shell-programmin...ng-output.html
# 3  
Wrench

Quote:
Originally Posted by Vikram_Tanwar12
I guess this has been answered in this thread

https://www.unix.com/shell-programmin...ng-output.html
It has not been answered and that is the very reason I opened the new thread. I want them to be stored in variables which is the addressed in the previous thread. Kindly help.
# 4  
Why don't you help yourself? That would be very educational! All pieces of the puzzle (parts of the solution) are given in that previous thread, you just need to get your ducks in a row.
# 5  
Quote:
Originally Posted by RudiC
Why don't you help yourself? That would be very educational! All pieces of the puzzle (parts of the solution) are given in that previous thread, you just need to get your ducks in a row.
If your intention is to question my naive skills on unix and / or the efforts put in then below is what i unsuccessfully tried.

Code:
eblogic_jdk_home=$($pscmd $weblogic_pid | awk 'BEGIN{X[1]="java_home="}{for(i=1;i<=NF;i++){if($i ~ /java$/){split($i,P,"=");s=P[2]?P[2]:$i;print X[++a]""s}}}')

But it does not give me the desired output. Can you help find me a solution ?
# 6  
Well, honouring your little effort, I'll try my best. That is not so easy - your wishes and specifications change form post to post and from thread to thread. Pulling some info together from the various sources, and given the fact that I can't duplicate your ps output so I use a file input, I've come up with
Code:
TMP=$(awk       '/java/         {printf "/%s/%s", $2, $3}
                 /platform/     {printf "|%s\n", $NF}
                ' FS="/" RS=" +" file )
weblogic_home=${TMP#*|}
java_home=${TMP%|*}
echo $java_home $weblogic_home
/app1/jdk150_07 weblogic92

It is well possible that your awk implementation does not accept e.g. the RS pattern; then we need to play on...
# 7  
Code:
var=`ps -xef | grep <pid>`
echo $var|tr " " "\n" | grep jdk150_07|sed "s/^/java_home=/g"
echo $var|tr " " "\n"|grep platform|sed 's/-Dplatform.home=/weblogic_home=/g'

Check out if you get the required o/p

Last edited by Franklin52; 02-27-2013 at 09:36 AM.. Reason: Please use code tags for data and code samples
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #965
Difficulty: Medium
The HTML syntax requires a doctype to be specified to ensure that the browser renders the page in standards mode.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract values only for certain tags

Hi Please I need help on extracting values, of certain tagsMSISDN:, and IMSI: in the following text file entryDS: 1 nodeId: 11 MSISDN: 258827475309 IMSI: 643012111658984 NAM: 0 CDC: 41 IMEISV:: U3URIGF2hoc= AUTHINFO: 0 TSMO:... (16 Replies)
Discussion started by: fretagi
16 Replies

2. Shell Programming and Scripting

Extract values

hi I have a line as given below. I need to match "COLUMN_NAME" and get the every third value ie words in between quotes completely (' ') Sample Input - COLUMN_NAME Like '%value%' Or COLUMN_NAME Like '%value%' Or COLUMN_NAME Like '%value value%' Or COLUMN_NAME Like '%value%' OR... (5 Replies)
Discussion started by: Prashanth B
5 Replies

3. Shell Programming and Scripting

Extract multiple values from a tnsping output

Hi all, Can anyone help with the following request? I need to extract HOST value, SERVICE_NAME and msec value from a tnsping output and append to a file. The tnsping output is typically as follows: Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS =... (4 Replies)
Discussion started by: jonnyd
4 Replies

4. Shell Programming and Scripting

Extract values of duplicate keys

I have two questions that are related, so it would be great if you can help me with both! Question1: I have a file A that looks like this: a x b y b z c w I want to get something like: a x b y; z c w Given that a,b,c has no spaces. But the other letters might contain spaces. ... (2 Replies)
Discussion started by: Viernes
2 Replies

5. Shell Programming and Scripting

extract key values

I am parsing a log with key values spread all over in the following fashion: TEST 1 SCHEME 12 SET EMPTY VARLEN SET TEST 1201 PARAM1 EMTY PARAM2 SET SCHEME 12 REFRESH TEST 8 I need to extract test number, my result should be 1 1201 8 I use awk for processing this log and use... (4 Replies)
Discussion started by: migurus
4 Replies

6. UNIX for Dummies Questions & Answers

Extract minimum values among 3 columns

Hi. I would like to ask for helps on extracting a minimum values among three columns using gawk in tab separator. input file: as1 10 20 30 as2 22 21 23 as3 300 391 567 as4 19 20 15 Output file: as1 10 as2 21 as3 300 as4 15 I am extremely appreciate your helps and comments.... (2 Replies)
Discussion started by: Amanda Low
2 Replies

7. Shell Programming and Scripting

Extract Values from CSV

Hi, I need to extract values from a CSV file based on some conditions as explained below: File format details: 1. each set starts with AAA only 2. number of columns is fixed 3. number of rows per set may vary (as they are having different CCC rows) Now, i need to extract 3rd column of... (3 Replies)
Discussion started by: prvnrk
3 Replies

8. Shell Programming and Scripting

Extract XML Element Values

I have a rather large file with XML-style content. Each line contains one full XML entry. For example: 1:<Message><DNIS>1234</DNIS><UCID>3456</UCID><TransferGroup>XYZXYZ</TransferGroup></Message> 2:<Message><DNIS>9999</DNIS><UCID>2584</UCID><TransferGroup>ABCABC</TransferGroup></Message>... (1 Reply)
Discussion started by: sharpi03
1 Replies

9. Shell Programming and Scripting

how to extract values b/w two delimiters

Hi, Please help me to extrat values b/w two delimiters. $ echo $abc i want to extract the value 12345 b/w %. (5 Replies)
Discussion started by: tsaravanan
5 Replies

10. Shell Programming and Scripting

Extract values from log file

I would like to write a shell script that will parse through a file similar to the sample below. The data in the file is redirected from rsync into a log file. I would like to call a shell script to parse through and pick out the number beside the percent sign inside the parentheses in the last... (5 Replies)
Discussion started by: wdympcf
5 Replies

Featured Tech Videos