Displaying current user process


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

You could do this...
cat felix.whoals | awk '
{
cmd=sprintf("ps -au %s",$1);
print cmd
system (cmd);
}'
Jmt
# 9  
Old 12-16-2007
So this cannot be solved without awk and sed? I do not want to use these two commands because I want to use the long way to do it. Do you have another solution without using awk?
# 10  
Old 12-16-2007
Quote:
Originally Posted by felixwhoals
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?
Programs are run by specifying a name and some optional arguments and additionally some IO redirection.

In the first case you refer to program called "head" with arguments "-1" and "abc".

In the second case you refer to a program called "ps" with arguments "-au", "head", "-1" and "abc".

Do you mean
Code:
ps -au `head -1 abc`

so that the output of "head -1 abc" becomes a command line argument?
# 11  
Old 12-16-2007
Quote:
Originally Posted by felixwhoals
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
Code:
ps -au `cat filename`

# 12  
Old 12-16-2007
So many ways, but this is the simplest

There might be 1000 good ways to do this, but you probably won't find one any better, shorter, or less complicated. The example can be done in one line, just takeout the newlines and the print statement. If you want to print the cmd, the statement probably needs to look like: print(cmd); (notice the parens and semi colon).
Jmt
# 13  
Old 12-16-2007
yes.

ps -au `head -1 abc` where head -1 abc gives me an argument (username) and then I could use it to get the process running for the current username.

Do you know the way to fix it?
# 14  
Old 12-16-2007
um,

Code:
echo $LOGNAME

will give the current user

Code:
ps -au `echo $LOGNAME`

would do want you want but can be simplified to

Code:
ps -au $LOGNAME

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