Shishir --

...and then Shishir K. Singh said...
% 
% Okay ...the scenario was...
% 
% 
% I telnet from my PC (remote host) to a UNIX machine with user ABC. Now I

So this is for your benefit rather than tracking down some other user,
right?  OK; good to know.


% can login from another PC on the same UNIX m/c as USER ABC, I just want
% to know the remote host name ("who -m" ) so that I can set my DISPLAY
% environment to the remote host

Ah.  OK.  I think I get it.


% 
% I have achieved it for the time being by putting the following in my
% .cshrc (cshell) by doing 
% 
% setenv DISPLAY  `who -m | sed 's/.*(\(.*\))$/\1/'`:0.0

So if you sit at PC and you log in on UNIX and then further log in on
LINUX, this setenv command will set your display to UNIX even though
you're sitting at PC, and that's what you want to replicate, right?

Unless this is a study exercise, if you're happy with that limited
behavior, why not just do it that way? :-)

If we can assume that you'll be doing this check on a *NIX machine where
who will always be available, then who is probably the way to go.  So all
you'd need to do is check your tty to know which line to reference and
then open a system call to who and parse out that line and then spit out
that machine name, hoping that you're really on :0.0, and call it as

  setenv DISPLAY `whom.pl`

or such.  That's just simple string matching.

If I were trying to code up such a thing, I'd take a look at how I could
really capture my machine and display and head and forward it along so
that the xterm gets thrown back to where I really am.  If you're using
ssh, some of that should already be in the environment for you.  If you're
using telnet or rsh, you can overload $TERM (eg xterm=UNIX:3.1) and then
take it apart again on the other side (and then reset your term to pick
up the changes).  In general, it's not sufficient to look on the remote
machine to see from whence you've come because it only knows what was
one step away and doesn't know anything about the display.


HTH &  HAND

:-D
-- 
David T-G                      * It's easier to fight for one's principles
(play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie
(work) [EMAIL PROTECTED]
http://www.justpickone.org/davidtg/    Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Attachment: msg25665/pgp00000.pgp
Description: PGP signature

Reply via email to