Help with who am i . Not displaying real user


 
Thread Tools Search this Thread
Operating Systems Solaris Help with who am i . Not displaying real user
# 8  
Old 03-18-2011
Try this (ksh or bash):

Code:
a=$(tty) ; w=$(w) ; a=$(echo $a | sed 's/\/dev\///') ; echo "$w" | grep -w "$a" | nawk '{print $1}'

# 9  
Old 03-18-2011
Quote:
Originally Posted by jlliagre
Try this (ksh or bash):

Code:
a=$(tty) ; w=$(w) ; a=$(echo $a | sed 's/\/dev\///') ; echo "$w" | grep -w "$a" | nawk '{print $1}'

Hmmmm..... it works on most of my servers, execpt this very one. I think it must be the way this particular server was built.

It doesn't output anything now on this particular server... When I broke the code down bit by bit, this is the output:
Code:
root@ # a=$(tty)
root@ # w=$(w)
root@ # a=$(echo $a | sed 's/\/dev\///')
root@ # echo "$w"
4:45pm up 188 day(s), 8:28, 1 user, load average: 0.00, 0.00, 0.01
User                             tty                login@      idle     JCPU      PCPU         what
<myusername>           pts/1       4:43pm        w
root@ #
root # echo "$w" |grep -w "$a"
root@ #

thanks for your help thogh, I guess I have to keep searching....

Last edited by pludi; 03-18-2011 at 02:55 PM..
# 10  
Old 03-18-2011
It would help if you post the tty command output (or $a value).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Real, effective and saved user id in C program

I figured it out by now. (0 Replies)
Discussion started by: Ralph
0 Replies

2. UNIX for Advanced & Expert Users

Regarding real example of user of semicolon(;) and + in find/exec command.

Hello All, Was recently working on an requirement where we have to search files more than a specific number, following is the example on same. Let's say file names are test_40000.txt,test_40001.txt and so on till test_99999.txt. Now requirement was to search from find command only those... (1 Reply)
Discussion started by: RavinderSingh13
1 Replies

3. Shell Programming and Scripting

Adding user name to file, and then displaying new line number

Hi all - I'm completely stumped by a script I'm working on... The short version is I have a file called 'lookup' and in it are hundreds of names (first and last). I have a script that basically allows the user to enter a name, and what I need to have happen is something like this: Record... (8 Replies)
Discussion started by: sabster
8 Replies

4. Shell Programming and Scripting

Wget script to simulate real user visits

so i'm using the following script to attempt to simulate a user visiting a page but unfortunately, it doesn't look like this is working: wget -nv -r "http://www.mywebsite.com" does anyone have a better idea of how to do this? the goal here is to run a wget command from a linux host to a... (3 Replies)
Discussion started by: SkySmart
3 Replies

5. Shell Programming and Scripting

In real time - what user connects or disconnect

Write a tool that will be displayed in real time, what user connects or disconnects from a system that uses this tool :)) Maybe anyone can help me? (2 Replies)
Discussion started by: titasas
2 Replies

6. Shell Programming and Scripting

Displaying default values when accepting input from user

Is there a way to display the default answer when accepting input from the user in the unix script.. e.g. ans="n" read $ans?"Enter y to continue n to exit:" altough ans contains n the message doesn't display the current contents on ans .. you get Enter y to continue n to exit: (8 Replies)
Discussion started by: flopster
8 Replies

7. Shell Programming and Scripting

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... (14 Replies)
Discussion started by: felixwhoals
14 Replies

8. Shell Programming and Scripting

how to get real user name

I know that in order to get a real user name I should use the following command: cut -d: -f5 /etc/passwd. But how can I get the real user name for those users who are currently logged in to the system??? :confused: Can somebody help me??? (3 Replies)
Discussion started by: aga
3 Replies

9. Shell Programming and Scripting

Collecting & Displaying of Last User ID and Date of Last Login

Hi, I needed to write a script to "Collect and Display the Last User ID and Date of Last Login". The requirement is: When a workstation stops reporting it could be for many reasons. If we know the last person who logged in before the workstation came down, then we can contact the last... (1 Reply)
Discussion started by: amittal
1 Replies

10. UNIX for Dummies Questions & Answers

Collecting & Displaying of Last User ID and Date of Last Login

Hi, I needed to write a script to "Collect and Display the Last User ID and Date of Last Login". The requirement is: When a workstation stops reporting it could be for many reasons. If we know the last person who logged in before the workstation came down, then we can contact the last... (1 Reply)
Discussion started by: amittal
1 Replies
Login or Register to Ask a Question