The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 02-14-2008
goldfish goldfish is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 18
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
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:29 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0