![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| printing each users by processes | sam4now | Shell Programming and Scripting | 12 | 04-28-2008 06:11 PM |
| Processes and Users | barbus | Shell Programming and Scripting | 22 | 10-03-2007 07:09 PM |
| displaying the users | needyourhelp | UNIX for Dummies Questions & Answers | 1 | 09-13-2007 01:37 AM |
| users and there processes | iago | UNIX for Dummies Questions & Answers | 3 | 09-10-2007 02:51 PM |
| Users and processes | Chiefos | UNIX for Dummies Questions & Answers | 17 | 06-17-2006 04:16 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Outputting the processes of current users to a file
Hi guys,
I'm writing a script to display all the current logged on users and the processes they're running, output to a file. The output will look similar to this: User1 (Real name not login name) PID TTY TIME CMD 3179 pts/3 00:00:00 vim User2 PID TTY TIME CMD ....etc The users should not be displayed more than once. So far i've got: USERS=`finger | awk '{print $1 "\t" $2 "\n"}'` I figure i'll use ps -u username but how do i take the username from $USER and apply it to the ps? Any help greatly appreciated, as i'm just starting out with UNIX! Thanks in advance, Oliver Last edited by olimiles; 08-18-2006 at 11:09 AM.. Reason: original title made question look trivial! |
|
||||
|
Thanks tmarikle!
There is 1 problem for each code you gave me: 1st code: I get a 'nawk does not exist' error, changing it to awk works but i'm thinking that the nawk adds the users name above each entry? 2nd code: the ps gets an error that the User name does not exist, but the rest still runs and i get the details i need, though again without the User's name at the top of each entry! Also, is there an easier way to change which columns are output ie just the PID, TTY, Time and CMD or should i just stick to formatting the results after they're put into the file? Thanks again, it's much appreciated and i'm still learning! Oliver Last edited by olimiles; 08-18-2006 at 03:16 PM.. Reason: worked out how to output results to file :o |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|