Re: Solaris 5.8 - need way to collect source host information




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

.



Relevant Pages

  • Re: Matlab crashes
    ... Michael Wild wrote in ... When I launch the program from command window, ... Operating System: Microsoft Windows XP ... The only command that I use is "write", ...
    (comp.soft-sys.matlab)
  • Re: Selecting a record froma table where a column might be null
    ... Chuck Fox wrote: ... > Michael and others ... > Your Friendly Neighborhood DBA, ... to do this with perl and the bind command, ...
    (perl.dbi.users)
  • Re: winzip in macro
    ... > which lets you enter command switches with the Basic Winzip command. ... > The one "gotcha" I never got past was that unless the user is using Outlook, ... One of these days I'm going to write a macro to use ... > "Michael" wrote in message ...
    (microsoft.public.excel.programming)
  • Re: Win32_Process CommandLine returning Null
    ... Thanks for the reply Michael. ... properties come back as Null if the process is running under an account ... I noticed that the MSFT iisapp.vbs script asserts the '' privilege ... the following command correctly shows me the w3wp ...
    (microsoft.public.win32.programmer.wmi)
  • Re: Solaris 5.8 - need way to collect source host information
    ... using a common login. ... command was used to get the connection source in the first place, ... is my last login if this command is run by me. ... while -F ' ' forces it to treat Tabs as normal characters. ...
    (comp.unix.shell)