zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Timothy J Luoma <luomat+Lists/Zsh/users@luomat.peak.org>,
	zsh-users@math.gatech.edu
Subject: Re: Is there a way to find the Remote Host in ZSH?
Date: Mon, 29 Jun 1998 14:41:54 -0700	[thread overview]
Message-ID: <980629144154.ZM5213@candle.brasslantern.com> (raw)
In-Reply-To: <199806292026.QAA10696@ocalhost>

On Jun 29,  4:26pm, Timothy J Luoma wrote:
> Subject: Is there a way to find the Remote Host in ZSH?
> 
> I am looking for a way to get the complete hostname or IP address where I  
> have connected _from_ when making a telnet/ssh/etc connection.

There really isn't any good way to do this from the shell, AFAIK.  If you
have the descriptor of the socket on which the connection is established,
you can use the getpeername() call from a C program, but that descriptor
may be hard to get at by the time you have a running shell.

The closest you can probably get is parsing or grepping the output from
"netstat", but that'll show you -all- connections without any way to tell
for sure which one of them is yours, so you'd be doing a bit of guessing.
It may not be unmanageable if you're unlikely to be logged in to the same
place twice and no one else from your local machine is likely to be logged
in to the same remote one.

A -very- crude approximation would be

	if netstat -tn | grep -sw 123\\.123\\.12\\.3; then
	    : whatever
	fi

> Something like REMOTE_IP or REMOTE_HOSTNAME (I think tcsh has something
> like that).

I can't find any mention thereof in the tcsh man page; all I could find
was the %M format for the "who" variable, which reads the utmp file same
as "who am I".


      parent reply	other threads:[~1998-06-29 21:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-29 20:26 Timothy J Luoma
1998-06-29 21:35 ` Sweth Chandramouli
1998-06-29 22:31   ` Bart Schaefer
1998-06-29 22:58     ` Geoff Raye
1998-06-29 21:41 ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=980629144154.ZM5213@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=luomat+Lists/Zsh/users@luomat.peak.org \
    --cc=zsh-users@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).