zsh-users
 help / color / mirror / code / Atom feed
* Why can't I get my remote host into a variable?
@ 2005-12-01  0:40 Lists
  2005-12-01  0:51 ` Geoff Wing
  0 siblings, 1 reply; 2+ messages in thread
From: Lists @ 2005-12-01  0:40 UTC (permalink / raw)
  To: zsh-users


Zsh 4.2.5 on FreeBSD.  I'm ssh'ing into the FreeBSD machine.

I'm trying to get my remote host into a variable REMOTE_HOST.  I have 
tried both of these in .zshenv:

REMOTE_HOST=`who am i | awk '{print $NF}'|tr -d '(|)'`

$ who am i
luomat           ttyp0    Nov 30 19:34 (192.168.1.103)

That works on the commandline, but when I try it in .zshenv I get 
"19:34" or whatever the timestamp is for that session.

Thinking I would be clever, I tried this

TTYSHORT=`echo $TTY |colrm 1 8`
REMOTE_HOST=`w | fgrep $TTYSHORT | awk '{print $3}'`

but that does not work either.

Anyone know how to get this to work in .zshenv?






^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Why can't I get my remote host into a variable?
  2005-12-01  0:40 Why can't I get my remote host into a variable? Lists
@ 2005-12-01  0:51 ` Geoff Wing
  0 siblings, 0 replies; 2+ messages in thread
From: Geoff Wing @ 2005-12-01  0:51 UTC (permalink / raw)
  To: Zsh Users

On Thursday 2005-12-01 11:40 +1100, Lists output:
:Zsh 4.2.5 on FreeBSD.  I'm ssh'ing into the FreeBSD machine.

You're presuming that the utmp/x is updated by the time zsh runs.
I wouldn't.  It's most likely to be asynchronous.

Instead, see which environmental variables sshd provides for you:
i.e. check if  SSH_CLIENT  or  SSH_CONNECTION  is available to you
and parse one of them.

Regards,
Geoff


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-12-01  0:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-01  0:40 Why can't I get my remote host into a variable? Lists
2005-12-01  0:51 ` Geoff Wing

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).