Displaying current user process


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Displaying current user process
# 1  
Old 12-16-2007
Displaying current user process

When I typed in ps -a I get this:

PID TTY TIME CMD
31799 pts/3 00:00:00 vim
31866 pts/3 00:00:00 vim

And to check who is currently logged in, I type who
Felix Whoals
Tada Whoals
Lala Whoals

How can I get the user process for all current users who logged in?? I think I need to combine both ps -a and who but don't know which command to use.

The result has to be something like this:

Felix Whoals
PID TTY TIME CMD
31799 pts/3 00:00:00 vim
31866 pts/3 00:00:00 vim

Tada Whoals
PID TTY TIME CMD
8368 pts/0 00:00:00 vim

Lala Whoals
PID TTY TIME CMD
31799 pts/3 00:00:00 vim
31866 pts/3 00:00:00 vim

I just want to know the commands to be used. I think this is pretty easy but I just couldn't figure it out the solution.
# 2  
Old 12-16-2007
I would use "who" to see who is logged in.

Then build a list of usernames and ensure it has no duplicates.

Then use "ps -u <username>" to get their processes.
# 3  
Old 12-16-2007
How's This

Not sure what OS you're running and this might be a tad over kill, but it may help you figure out your own solution:

for USER in `who | awk '{print $1}' | uniq`;do echo "PROCESSES RUN BY $USER";ps -a -u $USER;done

This one-line for loop loops through the names listed by the who command. Awk grabs the first column containing the names ($1), and uniq makes sure any duplicates are omitted. Then a header (PROCESSES RUN BY) followed by the user's name is printed. Under this heading are the processes being run by that particular user.

Hope this helps.
# 4  
Old 12-16-2007
Hi there,

I have a question, when I do ps -au xxx, I get an answer for user xxx.. I have a filename call abc and when I do head -1 abc i get an output of xxx too. Why can't I do ps -au head -1 abc?
# 5  
Old 12-16-2007
You need to follow the syntax for ps . The -u means user. It doesn't accept commands along with it.
# 6  
Old 12-16-2007
Well because when I do head -1 abc it gives me a username. therefore when I do ps -au head -1 abc, I should get an answer shouldn't I?

May I know how can I solve this problem?
# 7  
Old 12-16-2007
ps question

This is quite a simple question I have a file with my username in it.
So if I type cat filename, I get felix.whoals
TO show the current process that I am doing, I need to type ps -au felix.whoals

I want to get my username from the filename that I have created.
I was trying with ps -au | cat filename but this gives me an error.

Does anyone know how can I check my current processes by getting my username from the filename instead of entering it manually?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

PS output is not displaying full process running

I have 4 HPUX 11.31 servers with the same Quality Pack bundles. "AS FAR AS I CAN TELL" no system files have been modified. /usr/bin/ps is the same date size and creation date terminfo file (x-->xterm) is the same date size and creation date shell (ksh) is the same date size and creation date ... (4 Replies)
Discussion started by: mrmurdock
4 Replies

2. Shell Programming and Scripting

List Process running under current user

Hi, i need to list the processes running only under current logged in user. EX: $ whoami oraaqw $ ps -ef | grep tnslsnr oraaqw 11403300 19267592 0 09:14:47 pts/3 0:00 grep tnslsnr oraaqw 15794208 1 0 Jan 14 - 11:59... (6 Replies)
Discussion started by: aravindadla
6 Replies

3. Shell Programming and Scripting

Displaying current date time of EDT in IST time

Hi Folks, My server time is in EDT. And i am sending automated mails from that server in which i need to display the current date time as per IST (GMT+5:30). Please advice how to display the date time as per IST. IST time leads 9:30 mins to EDT. and i wrote something like below. ... (6 Replies)
Discussion started by: Showdown
6 Replies

4. Shell Programming and Scripting

How to Login as another user through Shell script from current user[Not Root]

Hi Every body, I would need a shell script program to login as different user and perform some copy commands in the script. example: Supppose ora_toms is the active user ora_toms should be able to run a script where user: ftptomsp pass: XXX should login through and run the commands ... (9 Replies)
Discussion started by: ujjwal27
9 Replies

5. UNIX for Dummies Questions & Answers

Running different process from current process?

I have been having some trouble trying to get some code working, so I was wondering...what system calls are required to execute a different program from an already running process? (1 Reply)
Discussion started by: Midwest Product
1 Replies

6. Solaris

Help with who am i . Not displaying real user

Hi I'm trying to get the real username of any user running as root on my server. On one of my server running Sol 10, if I su to root and run who am i, it displays my username. which is what I want. But when I run it on another server, this time on Sol 8, it displays root as the user. Is... (9 Replies)
Discussion started by: wisdom
9 Replies

7. UNIX for Dummies Questions & Answers

Displaying the current working directory in prompt

Hi, I want that the prompt that is being displayed (i.e $ sign) should display always the current directory I am working in instead of that $ sign example: as we use PS1=patric and the prompt changes from $ to patric OR if we write the command PS1=`pwd` it will display the current... (5 Replies)
Discussion started by: premjotsingh
5 Replies

8. Shell Programming and Scripting

ps -ef does not displaying the running process

Hi, I am using the monitor shell script to check the particular process is running or not.If it is not running this monitor shell script will automatically start the process.I am using the ps -ef command to check the process availablity.But the problem is some times the ps -ef | grep "Process... (8 Replies)
Discussion started by: sureshbabuc
8 Replies

9. UNIX for Dummies Questions & Answers

Current Process Running.

Hi all, When I issued command ps -ef|grep Vinay in a UNIX machine, I got the following Vinay 22491 1 255 Jun 18 ? 294248:53 -sh Vinay 26628 1 255 Jun 18 ? 294237:33 -sh Could you tell me what all process is running ? Please explain each of the fields. Thanks... (4 Replies)
Discussion started by: coolbhai
4 Replies

10. UNIX for Dummies Questions & Answers

Displaying VERY long process names with ps -ef

Hi, I'm trying to display all process on an AIX server with the string SLRServer in them. Normally "ps -ef|grep SLRServer" would be sufficient, however in this instance the process name is enormous and the part which contains this string has been truncated, as you can see in the example below ... (8 Replies)
Discussion started by: m223464
8 Replies
Login or Register to Ask a Question