"who am i" in AIX


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users "who am i" in AIX
# 1  
Old 10-01-2013
"who am i" in AIX

I have built a custom utility in shell script to deploy some files across AIX 6 servers.. I am using the "who am i" command to find out the IP address of the user who is using the utility to deploy the files for audit purpose.

This command returns the output with the user IP address on one server as:
Code:
user1 pts/5       Sep 30 12:47     (XX.YYY.ZZ.AAA)

but the other server does not return the IP address
Code:
user2 pts/16

I have looked around --unsuccessfully-- on this forum before putting this as a new post.. any pointers will be appreciated.

Last edited by Scrutinizer; 10-02-2013 at 04:54 PM..
# 2  
Old 10-01-2013
I've seen this happen before, but never discovered why. If you just need the IP Address that current user running the script connected from and they connected via ssh, you can get it from the SSH_CONNECTION environment variable. The following will return the IP Address.

Code:
echo ${SSH_CONNECTION%% *}

These 2 Users Gave Thanks to in2nix4life For This Post:
# 3  
Old 10-02-2013
"who am i" in AIX

yeah that works.. thanks! but still i am curious why the behavior of who am i is different..
# 4  
Old 10-02-2013
You're welcome.

I'm curious as well, but at the time that it occurred, I didn't cycles to figure it out, opting for a workaround instead. I've only seen it happen on the one AIX box and haven't seen it occur since.
# 5  
Old 10-28-2013
The difference is the login session: in one case it originated from a terminal ("pts/<n>" is a terminal), in the other case it is from a network line. Only the latter carries an IP address because only here the login process (this is what ultimately feeds "who am i"s output) is aware that there is a network connection involved.

In the other case there might be a network connection involved too, but only to acquire a (virtual) terminal and then use this to log in.

If you need the IP address you are coming from inspect the established network connections, because regardless of the method there must be an established TCP connection behind every session.

Code:
# netstat -an | grep ESTABLISHED

I hope this helps.

bakunin

/PS:

This will not work if you use some "man-in-the-middle" to connect: some "putty" over Citrix or similarly working products will show you the IP of the Citrix server, not your own.

Last edited by bakunin; 10-28-2013 at 06:42 AM..
These 3 Users Gave Thanks to bakunin For This Post:
# 6  
Old 10-31-2013
thanks!

was following this post everyday in hopes of an explanation Smilie thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

I need to find first daty of each month. What will I see on AIX "1" or "01"

Could you please let me know the following? I have to find and check first day of each month. I do fdt=`date +%d` will it give me on AIX "1" or "01" I ask you because I couldn't make real test on first day and don't know Thanks for contribution (4 Replies)
Discussion started by: digioleg54
4 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. AIX

How to enable "TCP MD5 Signatures" and "https" on AIX?

I have searched many times but nothing found. Somebody help please :(:(:( (1 Reply)
Discussion started by: bobochacha29
1 Replies

5. UNIX for Advanced & Expert Users

AIX - io info get from "libperfstat" not match "iostat"

Hi, everyone. I need to write a program to get io info based on libperfstat. But the "write time" of a disk is just half of the value get from iostat. I'm confused and can't explain. Help please. How I calculate "write service time per sec": In iostat: write service... (0 Replies)
Discussion started by: jackliang
0 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. AIX

AIX 5.3 - Discrepancies between "top" and "vmstat"

Can someone explain the differences I'm seeing below in TOP and VMSTAT commands on my AIX 5.3 server? Thanks! CPUs: 4; load averages: 0.86, 0.97, 0.97 18:09:26 926 processes: 4 stopped, 922 running CPU states: 78.4% idle, 8.5% user, 12.6% kernel, 0.3% wait Memory: 23680M Total.... (1 Reply)
Discussion started by: troym72
1 Replies

8. AIX

"pconsole" and "esaadmin" on AIX version 6

Anyone know what is the function of user "pconsole" and "esaadmin" on AIX version 6? (1 Reply)
Discussion started by: ebab3
1 Replies

9. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies
Login or Register to Ask a Question