9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Russ Cox" <rsc@plan9.bell-labs.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] /net like file trees and scripting.
Date: Wed,  2 Oct 2002 22:18:46 -0400	[thread overview]
Message-ID: <eb6451e178cd1eb62de69158f7804a17@plan9.bell-labs.com> (raw)

here's rlogin.

#!/bin/rc
# produce a zero byte on stdout
fn zero {
	dd -if /dev/zero -count 1 -bs 1 >[2]/dev/null
}

# translate a network address
fn cslookup {
	echo $1 | ndb/csquery >[2]/dev/null |tr -d '>'
}

# translate the network address for rlogin
x=`{cslookup net!$1!login}
if(~ $#x 0){
	echo couldn''t translate $1
	exit 'unknown host'
}
clonefile=$x(1)
dialstring=$x(2)

# hold the clone file open to keep the connection ours
<[4] $clonefile {
	netdir=`{basename -d $clonefile} ^ / ^  `{cat /fd/4}

	# write connect string to /net/tcp/N/ctl
	echo connect $dialstring >$netdir/ctl || exit 'cannot connect'

	# proxy data from remote system
	cat $netdir/data | tr -d '' &

	# must do bsd authentication protocol at beginning.
	{
		zero
	&&	echo -n $user	# local user
	&&	zero
	&&	echo -n $user	# remote user
	&&	zero
	&&	echo -n p9	# terminal type
	&&	zero
	} >$netdir/data || exit 'cannot talk bsd'

	# proxy data to remote system from keyboard
	# hold /dev/cons open to keep raw mode on
	</dev/cons >/dev/consctl {
		echo rawon
		cat >$netdir/data
	}
}



             reply	other threads:[~2002-10-03  2:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-03  2:18 Russ Cox [this message]
2002-10-05  8:31 ` Roman V. Shaposhnick
  -- strict thread matches above, loose matches on Subject: below --
2002-10-05  8:45 Geoff Collyer
2002-10-08 23:35 ` Roman V. Shaposhnick
2002-10-05  8:25 Charles Forsyth
2002-10-03  2:09 Roman V. Shaposhnick

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=eb6451e178cd1eb62de69158f7804a17@plan9.bell-labs.com \
    --to=rsc@plan9.bell-labs.com \
    --cc=9fans@cse.psu.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.
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).