- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- who -u does not show ssh connected users
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2007 05:08 AM
01-23-2007 05:08 AM
I have 2 systems, same patch levels, same O/S release, same software installed, one is the dev and other is prod.
# swlist |grep -i oe
HPUX11i-OE-Ent B.11.23.0505 HP-UX Enterprise Operating Environment Component
/etc/profile, /.profile/ sshd_config are identical.
Yet, on one server (prod), who -u does not show the ssh connected users...
Yet, when I strings /etc/utmp I see my name!
Also, who am i does not work either (on prod).
id does.
I have tried zeroing the utmp utmps btmp files...no luck...
Rgds...Geoff
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2007 05:17 AM
01-23-2007 05:17 AM
Re: who -u does not show ssh connected users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2007 05:32 AM
01-23-2007 05:32 AM
Re: who -u does not show ssh connected users
Now I have to wait for a reboot to see if it resolves itself.
During the meanwhile (always wanted to say that), how can I do the equivalent of `who am i` in the following?
We maintain a separate .sh_history file for each admin who su's to root.
In root's .profile we have:
# Set up logging
HISTFILE=${HOME}/.sh_history_`who am i|awk '{ print $1}'`
# there is something wrong with: print -s $(date) >>$HISTFILE
date >>$HISTFILE
export HISTFILE
HISTSIZE=5000
export HISTSIZE
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2007 05:33 AM
01-23-2007 05:33 AM
Re: who -u does not show ssh connected users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2007 05:43 AM
01-23-2007 05:43 AM
Re: who -u does not show ssh connected users
for your histfile question, what about using logname instead?
REAL_NAME=`logname`
HISTFILE=${HOME}/.sh_history_${REAL_NAME}
-denver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2007 05:49 AM
01-23-2007 05:49 AM
Re: who -u does not show ssh connected users
# Set up logging
# who am i breaks
#HISTFILE=${HOME}/.sh_history_`who am i|awk '{ print $1}'`
# find out who we are
PTY=`ps -ef |grep boks_sshd |grep -i grep |awk '{print $6}'`
export PTY
ADMIN=`ps -ef |grep @$PTY |grep -v grep |awk '{print $9}' |awk -F@ '{print $1}'`
export ADMIN
HISTFILE=${HOME}/.sh_history_$ADMIN
export HISTFILE
# there is something wrong with: print -s $(date) >>$HISTFILE
HISTSIZE=5000
export HISTSIZE
date >>$HISTFILE
As you see, we use boks here.
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2007 05:52 AM
01-23-2007 05:52 AM
Re: who -u does not show ssh connected users
root@mysvr011 [ / ]
# logname
epic0015
Should be gwild
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2007 06:01 AM
01-23-2007 06:01 AM
Re: who -u does not show ssh connected users
-denver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2007 06:04 AM
01-23-2007 06:04 AM
Re: who -u does not show ssh connected users
Same as all other servers.
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2007 06:41 AM
01-23-2007 06:41 AM
Re: who -u does not show ssh connected users
Got it down to this:
ADMIN=`ps -ef |grep $PPID |grep -v root |awk '{print $1}'`
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2007 09:14 AM
01-23-2007 09:14 AM
Solution> ADMIN=`ps -ef |grep $PPID |grep -v root |awk '{print $1}'`
This is incredibly unreliable. If PPID is 12 then process number 12 123 2212 34125 as well as command lines -t alltext12 and userID bill12 will all match. It is best to avoid ever using grep with ps. The main reason is that grep has a 100% accurate match for selected parameters. A rock solid replacement is:
ADMIN=$(ps -fp $PPID | awk '{print $1}')
Or even better by using the UNIX95 variable, you can drop the awk processing:
ADMIN=$(UNIX95=1 ps -p $PPID -o user=)
man ps has some very powerful exact match options such as -p and -u, and with UNIX95 set, -C gives an exact process name match. And these accurate options allow for multiple items such as -p 12,123,4567,2 -u billh,bill,joe4 -C sfd,sh,dm_stape UNIX95 also activates the -o option to customize the output from ps. And the = can be used to label the columns, with -o user= specifying no label at all. If all columns are set to null, then no column header is displayed.
Note also that `` (grave accents) have been deprecated for many years. Not only are they very difficult to read and mistake for '' but they cannot be nested. $() is the recommended syntax for modern shells.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2007 01:11 PM
01-23-2007 01:11 PM
Re: who -u does not show ssh connected users
I'm glad you jumped in Bill - thanks a lot for this:
ADMIN=$(UNIX95=1 ps -p $PPID -o user=)
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2007 01:31 AM
01-24-2007 01:31 AM
Re: who -u does not show ssh connected users
Bill, very strange result, now when I su to root, I see what appears to be 2 history files for me:
# ll
total 1154
drwx------ 3 root sys 96 Feb 28 2006 .mozilla
-rw-r--r-- 1 root sys 9 Feb 28 2006 .mozilla-license
-r--r--r-- 1 bin bin 1722 Jan 24 07:26 .profile
dr-x------ 3 root sys 96 Mar 27 2006 .secure
-rw------- 1 root sys 43068 Jan 23 12:34 .sh_history_
-rw------- 1 root sys 10058 Aug 15 16:06 .sh_history_admin1
-rw------- 1 root sys 8746 Jan 24 07:29 .sh_history_gwild
-rw------- 1 root sys 50 Jan 24 07:28 .sh_history_gwild
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2007 01:34 AM
01-24-2007 01:34 AM
Re: who -u does not show ssh connected users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2007 01:52 AM
01-24-2007 01:52 AM
Re: who -u does not show ssh connected users
ps -fp $PPID | awk '{print $1}'
displays
UID
gwild
So I added a grep -v UID
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2007 05:44 AM
01-24-2007 05:44 AM
Re: who -u does not show ssh connected users
I don't know, if you tried
id -un
In your last solution, there is no need for a grep, instead
ps -fp $PPID | grep -v UID | awk '{print $1}'
use
ps -fp $PPID | awk 'NR {print $1}'
Your 'll' outout:
Two identical filenames in one directory?
There must be hidden characters in (at least) one filename!
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2007 05:52 AM
01-24-2007 05:52 AM
Re: who -u does not show ssh connected users
# ps -fp $PPID | awk 'NR {print $1}'
UID
gwild
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2007 06:11 AM
01-24-2007 06:11 AM
Re: who -u does not show ssh connected users
As the 'id' command works, perhaps you could change:
HISTFILE=${HOME}/.sh_history_`who am i|awk '{ print $1}'`
to:
HISTFILE=${HOME}/.sh_history_`id -un`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2007 06:19 AM
01-24-2007 06:19 AM
Re: who -u does not show ssh connected users
id -un
shows the current user id - ie root - not the person who su'ed to root.
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2007 06:22 AM
01-24-2007 06:22 AM
Re: who -u does not show ssh connected users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2007 06:25 AM
01-24-2007 06:25 AM
Re: who -u does not show ssh connected users
# logname
logname: could not get login name
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2007 08:41 AM
01-24-2007 08:41 AM
Re: who -u does not show ssh connected users
something was dropped:
ps -fp $PPID | awk 'NR>1 {print $1}'
mfG Peter
PS: For me id -un workes even with 'su' (HP-UX 11i; Solaris10).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2007 08:57 PM
04-19-2007 08:57 PM
Re: who -u does not show ssh connected users
If you echo "[$ADMIN]" you will probably see something like [gwild ] returned.
This is why you are seeing 2 history files listed - one with trailing spaces, one without.
Try simply:
ADMIN=`UNIX95= ps -p $PPID -o user= |sed 's/ //g'`.
This should get rid of the trailing spaces.
rm .sh_history_gwild* and next time you login you should just keep one correct history file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2007 01:33 AM
04-20-2007 01:33 AM
Re: who -u does not show ssh connected users
Rgds...Geoff