[Solved] How can I pull specific information from PS?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] How can I pull specific information from PS?
# 1  
Old 02-25-2014
[Solved] How can I pull specific information from PS?

I need to grab information from the output of the ps command.

For each line of ps output that contains
Code:
_progres -b

I need to get the word that follows
Code:
-p

. The "-p" can be anywhere after
Code:
"_progres -b"

.

Using grep to select the correct lines is no problem (e.g.
Code:
ps -ef|grep "_progres \-b|grep -v grep

). Or
Code:
ps -ef | awk ' /_progres \-b/ {print $0}'

. Although there maybe better ways.


It's what comes after that where I need some suggestions.

TIA Smilie
# 2  
Old 02-25-2014
Can you paste the output of the ps command?

May be something like this?
Code:
ps -eaf | awk '/_progres -b/{ gsub(/.*_progres -b.*-p/, x); print $1}'

--ahamed

Last edited by ahamed101; 02-25-2014 at 10:01 PM.. Reason: Updated code
# 3  
Old 02-25-2014
Try this:

Code:
 ps -ef | awk '/_[p]rogres /&&/-b/&&/-p / { gsub(/.* -p /, ""); print $1}'


Note with progress batch sessions, the -b can also appear anywhere on the line (even at the end):

Code:
chubler    17030 17024  0 02:02 ?        00:00:02 /usr/dlc/102b/bin/_progres -pf /u/learn/b2b.pf -p my-proc.p -param EFT=y -param TIMEOUT=1800 -b


Last edited by Chubler_XL; 02-25-2014 at 09:44 PM.. Reason: Provide good ps example
# 4  
Old 02-26-2014
Thanks to both of you for the replies.

Chubler, thanks for the reminder the -b can appear anywhere as well.

Solved!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pull out information from output logs

My scenario is as follows. 1. I have a reference file with the IP addresses and names $ cat ref.list 10.11.xxx.xxx AA 10.12.xxx.xxx BB 10.13.xxx.xxx CC 10.14.xxx.xxx DD 2. A script runs and gets me one of the IP addresses and puts it in a separate file, for e.g... (2 Replies)
Discussion started by: Nagesh_1985
2 Replies

2. Shell Programming and Scripting

[Solved] Extracting information from DDL's

Dear Experts, I need your help here. I have lot of teradata DDL's as follows, i want to extract field names , field attributes and NOT NULL information from DDL.Could you please help here. Sample DDL: CREATE MULTISET TABLE APS_CALL_IN_PICKUP_CANCELED ,NO FALLBACK , NO BEFORE... (2 Replies)
Discussion started by: srikanth38
2 Replies

3. UNIX for Advanced & Expert Users

[Solved] Unable to fetch the UNIX variable information

I am having a file called variable_info.ksh in that file I am having following global variable information like… EMAIL_PATH=/var/mail TMP_PATH=/home/tmp And we are having another temporary parameter file abcd.txt, in that file we are having the following information like… EMAIL|EMAI_PATH I... (4 Replies)
Discussion started by: mesahammad
4 Replies

4. Shell Programming and Scripting

[Solved] Editing the alphabet's based on position information

I do have a file of the following format file 1 >SAM ATGCTCCTTAGCTACGTAGCAAGTAGAAAAAA AGCGCGAGCATTGAAGCGGAGGAGAGGAGGA TGAGATGATGACCCAGTATAAAGAGTGATGAT like this above file. file 1 has 1000's of lines. I would like to edit this file1 using the information from file2 (see below), by... (16 Replies)
Discussion started by: Lucky Ali
16 Replies

5. Shell Programming and Scripting

[SOLVED] Pull lines older than N weeks

There is another post in the forums that is similar to what I am trying to do, however, the thread is closed. So, I am creating this new one to see if someone could help. I am trying to use the code Ahamed posted, and tweak it. With the info from the forum, I recreated the scenario the person... (8 Replies)
Discussion started by: karstenjhilton
8 Replies

6. Shell Programming and Scripting

pull out rows with specific criteria

Hi, I have a file with multiple columns and for column 5 I want to extract that row into another file if it is equal to or greater than a certain value. For example: FAR 4 5 7 LOP GAT 3 3 3 POL I want values that are greater than 5 for column 4. So the final file will look like... (1 Reply)
Discussion started by: phil_heath
1 Replies

7. Shell Programming and Scripting

Pull specific lines from long file based on formula

For people who want to pull a number of lines from a long file using a specific formula n (number of iterations in a loop) a (offset number) b (stretch factor) example with n {1..100} for (( n=1; n<101; n++ )); do awk -v n=$n 'NR==a+(b*n)' a=0 b=1 inputfile >>outputfile (2 Replies)
Discussion started by: sgruenwald
2 Replies

8. HP-UX

[Solved] processor type and bit information

Hi, I'm trying to download a compatible Oracle Client software for a HP-UX machine. I'd like to know if ... 1) HP-UX is 32 bit or 64 bit? 2) Processor type - Itanium or regular? when I execute uname -a I get HP-UX B.11.11 U 9000/800 728684161 unlimited-user license Based on the... (7 Replies)
Discussion started by: luft
7 Replies

9. Shell Programming and Scripting

Pull specific data from repetitive text?

Hi all, I have a bit of a problem with a loop that extracts repetitive text. Running /bin/index executable outputs this text to terminal: testing index 'scanthread'... collected 0 docs, 0.0 MB total 0 docs, 0 bytes total 0.012 sec, 0 bytes/sec, 0.00 docs/sec testing index 'scanpost'...... (6 Replies)
Discussion started by: TECK
6 Replies

10. Shell Programming and Scripting

cant get perl to pull information right

Hello, I cant get the perl script to pull the information from Sark DNS 4.X Options ACL Templates= and other= Can someone look at the script to see why and fix it please. FYI..Under Sark DNS 4.x ACL Templates= and other= has an indent/tab, not sure if thats the reason my the script... (24 Replies)
Discussion started by: richsark
24 Replies
Login or Register to Ask a Question