Listing users and processes.
Hi,
Is there a way to display users logged on and there processes on one print rather than using "ps -a" and "finger" and then merging the relavent fields with AWK? Cheers Mike |
Run 'w'. Does it display what you want?
-twantrd |
Never mind.
|
Quote:
Do you have any idea if this is possible? |
I suggest using "w" or "who" rather than "finger".
ie Code:
who -up |
Quote:
Nice one, thanks. Will check once I get home. Mike |
Hi again,
I can't seem to use the who -p option on my shell but I have found that if I type "ps -U" username then it lists the processes for that user, so If I can somehow extract the user names from who and then send then to "ps -U" one at a time then I should be okay, only trouble is I can't work out how to do it, it won't let me pipe the info. Any ideas? Cheers mike |
Hi,
I think I have it sorted, I need to find out how to make awk print " quotations marks, i tried preceding them with a backslash but it dont work, does anyone if its possible? Mike EDIT its okay, i got it sorted without them :) I needed to write a program which displayed users and there processes plus there TTY and time and came up with this : Code:
Code:
Mike |
A hint:
the problem you describe lies in the fact that the first line printed by "finger" is just a column header. So, modify your first awk to disregard this header row and you should be fine. Code:
awk '{print $1, $2, $3}' myfile | Code:
awk {if (NR>1) print $1, $2, $3}' myfile | |
Not sure what your EXACT intention is, but ...
Code:
ps -au | grep `who|cut -d" " -f1` OK, that was daft; doesn't work if there's more than one user logged in :} ... I'll think some more. [/edit] Ok, that works :} [edit2] Code:
ps -au|egrep `who|awk '{printf $1"|"}END{print""}'|sed 's/|$//g'` Cheers, Tink |
Quote:
That also conculdes the course work I have to do so I won't be bothering you anymore (at least not for a while). I must say a big thank you to everyone who helped. Thanks m8 Mike |
All times are GMT -5. The time now is 12:55 PM. |