finding original login name, not current name


 
Thread Tools Search this Thread
Operating Systems AIX finding original login name, not current name
# 1  
Old 02-19-2008
Question finding original login name, not current name

Hi all,

I've searched around and not found any specific solution to my problem, so wondered if someone out there could help.

I'm in the process of migrating some shell scripts from HP UNIX to AIX and one of the scripts uses the 'logname' command.

On HP 'logname' returns the login name, which is not necessarily the current user name.

But under AIX it returns the current user, not the login name.

i.e.
I telnet to a UNIX box as 'user1'.
I then use 'su - someotheruser' to switch to an application account (direct logins are not allowed due to security constraints).

If I run 'logname' under HP it returns 'user1'.
But under AIX it returns 'someotheruser'.

For the script I need to know who the actual user is, not the current user name that was switched to. (This is for audit reasons to keep tabs on who is doing what on the system).

So is there anyway to return the actual logon name used on AIX, rather than the current user name?

Cheers,
Mark
# 2  
Old 02-19-2008
Your only solution:
use "who am i" and keep the first field giving you the HP equivalent...

All the best
# 3  
Old 02-19-2008
Quote:
Originally Posted by vbe
Your only solution:
use "who am i" and keep the first field giving you the HP equivalent...
Already tried that, didn't work either.

Code:
huedgoat:webmeth /home/webmeth $who am i
webmeth   pts/2

webmeth is the user I switched to, using 'su' from my account, but it's my account name I need, not the current account.

Mark
# 4  
Old 02-19-2008
vbe@ ro3: /home/mbo> who am i
vbe pts/5 Feb 19 14:46 (draco)
vbe@ ro3: /home/mbo> id
uid=50287(mbo) gid=1(staff)
vbe@ ro3: /home/mbo> exit
vbe@ ro3: /home# id
uid=0(root) gid=0(system) groups=1(staff)
vbe@ ro3: /home# who am i
vbe pts/5 Feb 19 14:46 (draco)
vbe@ botero3: /home# su - mbo
vbe@ ro3: /home/mbo> id
uid=50287(mbo) gid=1(staff)
vbe@ botero3: /home/mbo> whoami
mbo
vbe@ ro3: /home/mbo> who am i
vbe pts/5 Feb 19 14:46 (draco)
vbe@ ro3: /home/mbo> oslevel
5.3.0.0
vbe@ ro3: /home/mbo>

Now looking at my prompt, it could be an alternative...
# 5  
Old 02-19-2008
While I was at it I looked at logname on that aix box, and it works fine...
so I would guess there is something not quite so right on your system, what OS is it? Arent you beeing fooled by some alias or home command?

Good luck
# 6  
Old 02-19-2008
It's AIX Version 5.3, a brand new box bought and installed a few months ago for a new platform we are building.

I think your right about a possible configuration problem with the box.

We have 9 new AIX boxes all 5.3 all should be set up the same. I'd only checked the first two, with the same results as above.

But after your comment I decided to try some of the others, as two of them were built by different people (as it was done at a different time), although to the same cook-book.

The forth box I tried worked correctly, returning the actual user not the account currently in use.

So looks like the initial boxes have been configured wrong somewhere, so I'll pass my findings on to the relevant team and see if they can figure out what they did wrong!

Thanks for you help, nice to get confirmation on how the command should have worked.

Regards,
Mark
# 7  
Old 02-20-2008
Greetings,

Did you try:
which logname
and:
ls -al /usr/bin/logname
-r-xr-xr-x 1 bin bin 2442 Jul 12 2004 /usr/bin/logname
vbe@ lo14: /> file /usr/bin/logname
/usr/bin/logname: executable (RISC System/6000) or object module

You might have been spoofed by a custom command or alias - have you tried by using the command with absolute path or going to /usr/bin and typeing ./logname to see if it changes something?

Good luck
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Can adding to a new group be effective in current login environment without re-login?

Hey folks, When a user is added to a new group, the user has to be log out and log in again to make the new group effective. Is there any system command or technique to refresh user group ID update without re-login? I am not talking about to use "login" or "su -l" commands which can only make... (2 Replies)
Discussion started by: hce
2 Replies

2. Solaris

Finding system uptime without login

Hi, Am writing a script where I want to find uptime of certain servers. Is there any command where we can find uptime without login to the server, since the server list is big logging to the server will time consuming. Thanks in advance (7 Replies)
Discussion started by: rogerben
7 Replies

3. Shell Programming and Scripting

Finding 4 current files having specific File Name pattern

Hi All, I am trying to find 4 latest files inside one folder having following File Name pattern and store them into 4 different variables and then use for processing in my shell script. File name is fixed length. 1) Each file starts with = ABCJmdmfbsjop letters + 7 Digit Number... (6 Replies)
Discussion started by: lancesunny
6 Replies

4. Shell Programming and Scripting

Finding files in current directory when 100,000's files in current directory

Hi All I was wondering what is the most efficient way to find files in the current directory(that may contain 100,000's files), that meets a certain specified file type and of a certain age. I have experimented with the find command in unix but it also searches all sub directories. I have... (2 Replies)
Discussion started by: kewong007
2 Replies

5. Shell Programming and Scripting

Finding files older than the current date and time and renaming and moving

Hi, I have a very urgent requirement here. I have to find all files in the specified directory but not in the sub directories(The directory name is stored in a variable) which are older than the current date as well as current time and rename it as filename_yyyymmddhhmmss.ext and move it into a... (7 Replies)
Discussion started by: ragavhere
7 Replies

6. Shell Programming and Scripting

finding 0 byte files in current directory only

Hi Gurus, I have a directory A, which has some 0 byte files in it. This directory also has a subdirectory B which also has some 0 byte files in it. The problem: I only need to find out the names of the 0 byte files in the directory A. I'm using the following command find . -name *.zip... (6 Replies)
Discussion started by: ramky79
6 Replies

7. Shell Programming and Scripting

Finding your current run lvl

The title says it all really. I am writing a shell script for a Linux box, and I have recently run into a problem. I need to make sure I am at a certain run level first. Hence, the question. How can I find out what run level the box is currently running at? Is there a system variable... (2 Replies)
Discussion started by: Scripting Newb
2 Replies

8. Programming

Finding largest file in current directory?

I was hoping to get some assistance with this C program I am working on. The goal is to find the largest file in the current directory and then display this filename along with the filesize. What I have so far will display all the files in the current directory. But, how do I deal with "grabbing"... (1 Reply)
Discussion started by: AusTex
1 Replies

9. UNIX for Dummies Questions & Answers

Finding out the current AIX Maintenance Level

Is there a simple command in the vein of `oslevel` under AIX 4.3 to show the current patch level of the machine? (2 Replies)
Discussion started by: sam_pointer
2 Replies

10. UNIX for Dummies Questions & Answers

Finding current working dir path

Hi Folks, In a Unix (ksh) script, is there a way to determine the current working directory path of another logged-in user? Of course, I can use "pwd" to find my own path. But, how do I find it for another active user? Thanks for any input you can provide. LY (6 Replies)
Discussion started by: liteyear18
6 Replies
Login or Register to Ask a Question