![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to extract first column with a specific character | selamba_warrior | Shell Programming and Scripting | 3 | 05-22-2008 06:14 AM |
| How to read a specific column into variable | victorcheung | Shell Programming and Scripting | 2 | 04-18-2008 02:49 AM |
| Identify specific processes from different Machine | tungaw2004 | Shell Programming and Scripting | 2 | 03-01-2007 11:50 AM |
| running isql 'ace' report from command line | pugsly62 | UNIX for Dummies Questions & Answers | 0 | 07-11-2005 04:45 PM |
| How do I Know if a report manager is running after I start it ? | rocker40 | UNIX for Dummies Questions & Answers | 2 | 10-20-2003 05:36 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Report running processes in a specific format (tricky column filtering)
First off I have HP Unix, so as far as I can tell the PS command does not let me list specifically which columns I would like or what order I would like to see them. I want to make a custom PS script for checking what SAS process are running. I want it to take 1 argument of user name and only report processes for that user. I also only want to report process that start with /sas/sas_8.2/sas. What I want to report for these processes is the last argument in there command statement (the count09.sas, the program being executed by sas) along with the ProcID, STIME and TIME. I'm having trouble parsing the PS statement, for one reason, because the amount of "columns" That awk sees before the command statement varies depending on the values in each column. Example say you get the following output Code:
$ps -efx|grep user023
user023 207 29975 0 09:21:16 pts/8 0:00 /bin/bash
user023 11512 115 3 15:33:09 pts/7 0:00 ps -efx
user023 29975 29974 0 09:20:17 ? 0:01 s
user023 29977 29975 0 09:20:17 pts/5 0:00 /bin/bash
root 28948 3519 0 09:12:16 ? 2:04 sshd: user023@pts/3
user023 11513 115 0 15:33:09 pts/7 0:00 grep user023
user023 19003 1 0 Feb 7 ? 0:00 /sas/sas_8.2/sas -autoexec /sas/autoexec_generic.sas -work /wk01/saswork count09.sas
user023 10863 1 252 15:24:07 pts/7 5:38 /sas/sas_8.2/sas -autoexec /sas/autoexec_generic.sas -work /wk01/saswork postpull06rev.sas
user023 115 29975 0 09:20:40 pts/7 0:00 /bin/bash
I would like to be able to type Code:
$p user023 Project Name ProcID Start Time postpull06rev.sas 10863 15:24:07 5:38 count09.sas 19003 Feb 7 0:00 My attempt so far only lists the running project names: Code:
$cat ~/bin/p #!/usr/bin/bash ps -efxa|sed -n 's/user023.*saswork//p'|grep .sas and has a hardcoded user name. Any ideas on an approach here? Awk columns has been falling short for me, and my script is still significantly lacking. Is there any way to do column management in my output script so that the titles line up with each column as well? To explain why awk columns won't work for me take the following output: Code:
$ ps -u user023 -xf|grep /sas|awk '{ print $13 "\t" $2 "\t" $5 "\t" $7 }'
postpull10rev.sas 8566 10:02:58 9:16
10905 10:24:15 0:00
/wk01/saswork 19003 Feb ?
See how postpull10rev.sas is the 13th column? but count09.sas is the 14th column? This is because STIME reads "10:02:58" in one and "FEB 13" in the other. Thanks, GoldFish |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|