ng@cfd.di.nrc.ca (Kai Ng) (03/21/91)
In AIX/RS6000, is there a way to find out from where you are actually login'ed ? In other unix like Iris, there is conveniently a shell variable REMOTEHOST set for you. However I can't find anything equivalent in aix. Thanks in advance. -- ----------------------------------------------------------------------------- Kai S. Ng Informatics, National Research Council Canada INTERNET ng@cfd.di.nrc.ca M-60 Montreal Road, Ottawa, Canada K1A 0R6 BITNET kain@nrcvm01.bitnet VOICE (613) 993-0240 FAX (613) 954-2561
jfh@greenber.austin.ibm.com (John F Haugh II) (03/21/91)
In article <1991Mar20.185405.5746@nrcnet0.nrc.ca> ng@cfd.di.nrc.ca writes: >In AIX/RS6000, is there a way to find out from where you are actually >login'ed ? In other unix like Iris, there is conveniently a shell >variable REMOTEHOST set for you. However I can't find anything equivalent >in aix. You can get this information either from /etc/utmp (if you are looking for a C solution) or straight out of the "who" command if shell will do for you. This is what I get on this machine - % who | grep jfh jfh pts/9 Mar 20 16:01 (snowball.austin.) Regrettably you don't get all of it because the u_host field is only 16 characters long. -- John F. Haugh II | I've Been Moved | MaBellNet: (512) 838-4340 SneakerNet: 809/1D064 | AGAIN ! | VNET: LCCB386 at AUSVMQ BangNet: ..!cs.utexas.edu!ibmchs!auschs!snowball.austin.ibm.com!jfh (e-i-e-i-o)
ng@cfd.di.nrc.ca (Kai Ng) (03/21/91)
In article <6034@awdprime.UUCP>, jfh@greenber.austin.ibm.com (John F Haugh II) writes: |> In article <1991Mar20.185405.5746@nrcnet0.nrc.ca> ng@cfd.di.nrc.ca writes: |> >In AIX/RS6000, is there a way to find out from where you are actually |> >login'ed ? |> |> You can get this information either from /etc/utmp |> or |> |> % who | grep jfh |> jfh pts/9 Mar 20 16:01 (snowball.austin.) |> |> Regrettably you don't get all of it because the u_host field is only |> 16 characters long. |> -- |> John F. Haugh II | I've Been Moved | MaBellNet: (512) 838-4340 The who command would work only in a few cases. It fails if you have login'ed more than once from more than 1 place; or as you suggested the remote host name is long. On top of that 'who' has a bug, which I hope it is fixed in 3003, that it still lists, quite often, users who have logoff'ed. Somewhere in the system must this information be stored. However I do prefer to have a shell solution. Thank you. -- ----------------------------------------------------------------------------- Kai S. Ng Informatics, National Research Council Canada INTERNET ng@cfd.di.nrc.ca M-60 Montreal Road, Ottawa, Canada K1A 0R6 BITNET kain@nrcvm01.bitnet VOICE (613) 993-0240 FAX (613) 954-2561
crow@waterloo.austin.ibm.com (David L. Crow) (03/22/91)
>In AIX/RS6000, is there a way to find out from where you are actually >login'ed ? Following is the solution that I use for determining the host that I have logged in from. It is an all-shell solution that I use on a server for InfoExplorer so that the graphics version can be displayed on the X-Server from which you login. # The first statement sets the TTY variable to be what is returned from # the 'tty' command without the /dev/ ie if tty returned '/dev/pty/3', # then all we want is 'pty/3' # The second statement determines the display name for X to use. I use # who to determine which machine we are coming from. We grep on the tty # found in the previous step. The awk gets the last item on the line # (i.e. the hostname). The last item is of the form (host.domain...). The # sed will strip the parenthesis and the domain leaving only the hostname. # Then we append the ":0" to make it the display name. TTY=$(tty | sed 's/\/dev\///') DISPLAY=$(who | grep $TTY | awk '{print $NF}' | sed 's/(\([a-zA-Z0-9_]*\).*/\1/'):0 export TTY DISPLAY All that you should have to change is to take the ":0" off the end of the DISPLAY assignment statement and maybe change the name to something more meanningful like FROMHOST. I don't claim that this is the best or only solution. It is one that I came up with on the fly and it seems to work very well. The only problem that I have add is if the machine that you are logging in to cannot do internet ID to hostname translation correctly (ie the host is not defined in /etc/hosts or on the nameserver), then the value for DISPLAY will be set to the first octet of the internet address appended to ":0" since I use the period as a delimiter. If you have any questions feel free to ask (either by post or email). - This is only an exhibition, not a competition, so please....no wagering. - David Crow (512) 823-4834 IBM VNET: dlcrow@austin AIX Systems Graphics Development Internet: crow@waterloo.austin.ibm.com ------ Any opinions expressed are those of me and not of my employer. ------
ng@cfd.di.nrc.ca (Kai Ng) (03/23/91)
In article <6050@awdprime.UUCP>, crow@waterloo.austin.ibm.com (David L. Crow) writes: |> >In AIX/RS6000, is there a way to find out from where you are actually |> >login'ed ? |> |> # The first statement sets the TTY variable to be what is returned from |> # the 'tty' command without the /dev/ ie if tty returned '/dev/pty/3', |> # then all we want is 'pty/3' |> # The second statement determines the display name for X to use. I use |> # who to determine which machine we are coming from. We grep on the tty |> # found in the previous step. The awk gets the last item on the line |> # (i.e. the hostname). The last item is of the form (host.domain...). The |> # sed will strip the parenthesis and the domain leaving only the hostname. |> # Then we append the ":0" to make it the display name. |> |> TTY=$(tty | sed 's/\/dev\///') |> DISPLAY=$(who | grep $TTY | awk '{print $NF}' | sed |> 's/(\([a-zA-Z0-9_]*\).*/\1/'):0 |> export TTY DISPLAY |> |> - This is only an exhibition, not a competition, so please....no wagering. - |> David Crow (512) 823-4834 IBM VNET: dlcrow@austin |> AIX Systems Graphics Development Internet: crow@waterloo.austin.ibm.com |> ------ Any opinions expressed are those of me and not of my employer. ------ This little script should works perfect and could be a perfect solution to me. However, owing to the BUG in 'who' (which lists users who have already logoff'ed and so in the list there are entries with same tty number), it fails consistently. :-( Is this bug fixed in 3003? We've just got the update tape and have not applied it yet. Thanks for the solution. -- ----------------------------------------------------------------------------- Kai S. Ng Informatics, National Research Council Canada INTERNET ng@cfd.di.nrc.ca M-60 Montreal Road, Ottawa, Canada K1A 0R6 BITNET kain@nrcvm01.bitnet VOICE (613) 993-0240 FAX (613) 954-2561
davec@shared.uucp (Dave Close) (03/25/91)
In article <1991Mar21.140213.8928@nrcnet0.nrc.ca> ng@cfd.di.nrc.ca writes: >In article <6034@awdprime.UUCP>, jfh@greenber.austin.ibm.com (John F Haugh II) writes: >|> In article <1991Mar20.185405.5746@nrcnet0.nrc.ca> ng@cfd.di.nrc.ca writes: >|> >In AIX/RS6000, is there a way to find out from where you are actually >|> >login'ed ? >|> >The who command would work only in a few cases. It fails if you have login'ed >more than once from more than 1 place; or as you suggested the remote host >name is long. On top of that 'who' has a bug, which I hope it is fixed in >3003, that it still lists, quite often, users who have logoff'ed. 'who' also doesn't work if the user is logged-in via rexec or rsh. Re logged-out users, the utmpcln program posted a while ago seems to run fine on AIX. Sorry, I forget which group had the posting. -- Dave Close Shared Financial Systems Dallas davec@shared.com vmail +1 214 458 3850 uunet!shared!davec fax +1 214 458 3876 My comments are my opinions and may not be shared by Shared.
lenny@icus.ICUS.COM (Lenny Tropiano) (03/26/91)
In article <1991Mar22.201554.14530@nrcnet0.nrc.ca> ng@cfd.di.nrc.ca writes: |>In article <6050@awdprime.UUCP>, crow@waterloo.austin.ibm.com (David L. Crow) writes: |>|> >In AIX/RS6000, is there a way to find out from where you are actually |>|> >login'ed ? |>|> [...] |>This little script should works perfect and could be a perfect solution to me. |>However, owing to the BUG in 'who' (which lists users who have already |>logoff'ed and so in the list there are entries with same tty number), it |>fails consistently. :-( |> |>Is this bug fixed in 3003? We've just got the update tape and have not |>applied it yet. The bug doesn't have to do with "who" specifically, but with the update to the /etc/utmp and /usr/adm/wtmp files. The bug was in the telnetd and rlogind programs (if you don't have a network and don't use telnet or rlogin, you shouldn't have this problem). The telnetd problem was officially fixed in 2004 (the update after 3003) which is available from IBM. The rlogind problem will be fixed in 3005 which is to be autoshipped from IBM (much like the 3003 release) sometime late in April. -Lenny -- | Lenny Tropiano ICUS Software Systems lenny@icus.ICUS.COM | | ...!{ames,cs.utexas.edu,pacbell}!icus!lenny attmail!icus!lenny | +---------------- 14300 Tandem Blvd #222, Austin, TX 78728 -----------------+
chip@tct.uucp (Chip Salzenberg) (03/27/91)
According to ng@cfd.di.nrc.ca: >However, owing to the BUG in 'who' (which lists users who have already >logoff'ed and so in the list there are entries with same tty number) ... >Is this bug fixed in 3003? Sadly, no. We're at 3003 build 18 and the who bug is still there. -- Chip Salzenberg at Teltronics/TCT <chip@tct.uucp>, <uunet!pdn!tct!chip> "All this is conjecture of course, since I *only* post in the nude. Nothing comes between me and my t.b. Nothing." -- Bill Coderre
hbergh@oracle.nl (Herbert van den Bergh) (03/27/91)
In article <1991Mar25.033549.30276@shared.uucp> davec@shared.uucp (Dave Close) writes: >In article <1991Mar21.140213.8928@nrcnet0.nrc.ca> ng@cfd.di.nrc.ca writes: >> On top of that 'who' has a bug, which I hope it is fixed in >>3003, that it still lists, quite often, users who have logoff'ed. That bug is not fixed in 3003. We are running with 3003 for a few weeks now and who is still listing the incorrect utmp entries. >Re logged-out users, the utmpcln program posted a while ago seems to run fine >on AIX. Sorry, I forget which group had the posting. I'm interested in this program. Is it possible to mail or post it? Thanks. >-- > Dave Close Shared Financial Systems Dallas > davec@shared.com vmail +1 214 458 3850 > uunet!shared!davec fax +1 214 458 3876 > My comments are my opinions and may not be shared by Shared. -- Herbert van den Bergh, Email: hbergh@oracle.nl, hbergh@oracle.com ORACLE Europe --
jfh@greenber.austin.ibm.com (John F Haugh II) (03/27/91)
In article <1991Mar25.033549.30276@shared.uucp> davec@shared.uucp (Dave Close) writes: >'who' also doesn't work if the user is logged-in via rexec or rsh. To the best of my knowlege, "rsh" and "rexec" don't count as login sessions if for no other reason that there is no login tty associated. Try the "tty" command - what tty are you "logged-in" to? >Re logged-out users, the utmpcln program posted a while ago seems to run fine >on AIX. Sorry, I forget which group had the posting. I had posted a little diddie in alt.sources last fall. You might try looking there for what I posted. Sorry, I don't have a copy of the code at this address as I wrote it at home, so please don't send mail to this address asking for it. -- John F. Haugh II | I've Been Moved | MaBellNet: (512) 838-4340 SneakerNet: 809/1D064 | AGAIN ! | VNET: LCCB386 at AUSVMQ BangNet: ..!cs.utexas.edu!ibmchs!auschs!snowball.austin.ibm.com!jfh (e-i-e-i-o)
jfh@greenber.austin.ibm.com (John F Haugh II) (03/28/91)
In article <27EF7131.3C9B@tct.uucp> chip@tct.uucp (Chip Salzenberg) writes: >According to ng@cfd.di.nrc.ca: >>However, owing to the BUG in 'who' (which lists users who have already >>logoff'ed and so in the list there are entries with same tty number) ... >>Is this bug fixed in 3003? > >Sadly, no. We're at 3003 build 18 and the who bug is still there. I'm certain that you can find the utmp file cleanerupper that I posted in alt.sources last winter. Failling that, you can fix your utmp file by scanning the file for "USER_PROCESS" entries with ut_pid fields that do not have processes associated with them. Change the ut_type field to "DEAD_PROCESS" and zero out a few other fields in the (struct utmp) and then write that structure back out. This will fix the problem for now. As for why there are entries with the same tty name, I've never seen that one. Sounds like another problem altogether as the application should look to see if there is already an entry and use that one if it exists rather than appending a new one. -- John F. Haugh II | I've Been Moved | MaBellNet: (512) 838-4340 SneakerNet: 809/1D064 | AGAIN ! | VNET: LCCB386 at AUSVMQ BangNet: ..!cs.utexas.edu!ibmchs!auschs!snowball.austin.ibm.com!jfh (e-i-e-i-o)
karish@mindcraft.com (Chuck Karish) (03/30/91)
In article <1991Mar25.033549.30276@shared.uucp> davec@shared.uucp (Dave Close) writes: >'who' also doesn't work if the user is logged-in via rexec or rsh. 'rsh' without arguments is identical to 'rlogin'. 'who' works fine with it. Opening an 'xterm' or 'aixterm' window on the local host via an 'rsh' to the remote host ("rsh remotehost aixterm -display localhost") does not produce a usable response from 'who'. Of course, if you do this $DISPLAY is already set properly. Chuck Karish karish@mindcraft.com Mindcraft, Inc. (415) 323-9000