Re: Solaris 5.8 - need way to collect source host information
- From: "rooksmith" <rooksmith@xxxxxxxxx>
- Date: 10 Oct 2006 11:00:49 -0700
Thanks Michael - of course !! who am i (3words). for some reason I had
tried whoami which of course did nothing.
who am i piped to Awk worked fine for my purposes:
in c-shell : setenv SOURCE `who am i | awk -F' ' '{ print $6 }'`
in bourne: SOURCE=`who am i | awk -F' ' '{ print $6 }'`
Thanks
Michael Tosch wrote:
rooksmith wrote:
I need a way to trap information about the source computer for people
using a common login. In other words -- bert-pc is connected to
ernie-solaris . so I login to an account foobie, which is shared by 2
other people .
Now I want to automatically log information about the different users
in a way similar to sudo, but more subltle. So I can capture little
pieces from the "last" command via the .login (in c-shell) .
setenv SOURCE `last | head -1 | awk -F' ' '{ print $3 }'`
But there has to be a better way than that . Some sort of lexical
command was used to get the connection source in the first place, right
(maybe some flag for netstat ??)
If you happen to know, please reply...
Thanks
last -1
can be much faster than
last | head -1
last -1 $USER
is my last (current) login if this command is run by me.
The "last" command uses wtmp/wtmpx.
Many systems log the source host to utmp/utmpx, which you can query
by the commands
who
and
who am i
utmp/utmpx only keeps track who is currently logged on,
so these commands are much faster.
awk '{print $3}'
is usually safer because the field separator defaults to "whitespace"
(Spaces and Tabs)
while -F ' ' forces it to treat Tabs as normal characters.
--
Michael Tosch @ hp : com
.
- Follow-Ups:
- Re: Solaris 5.8 - need way to collect source host information
- From: Michael Tosch
- Re: Solaris 5.8 - need way to collect source host information
- References:
- Solaris 5.8 - need way to collect source host information
- From: rooksmith
- Re: Solaris 5.8 - need way to collect source host information
- From: Michael Tosch
- Solaris 5.8 - need way to collect source host information
- Prev by Date: Question on Associative Array in Bash shell
- Next by Date: Re: Question on Associative Array in Bash shell
- Previous by thread: Re: Solaris 5.8 - need way to collect source host information
- Next by thread: Re: Solaris 5.8 - need way to collect source host information
- Index(es):
Relevant Pages
|