.TH telnet "" "" "Command"
.PC "Communicate with a remote host"
\fBtelnet [\fIcommand\fB] [\fIremotehost\^\fB[\fIport\^\fB] ]\fR
.PP
The command
.B telnet
lets you log into another system on your network and work on it,
much as if you had logged into it directly.
.PP
Please note that the rest of this article uses the terms ``local host'' and
``remote host''.
In networking jargon, a
.I "local host"
is the machine that you have logged into directly, either via a serial
port or the console.
It is the machine from which you initialiate
.B telnet
transactions.
The
.I "remote host"
is the system you are trying to contact over the network.
The remote host can be a computer in the next room, or on the other
side of the planet.
It is the recipient of the commands you issue on the local host.
.SH "Using telnet"
If you invoke
.B telnet
without arguments, it enters command mode, as indicated by prompt:
.DM
	telnet>
.DE
.PP
If you name a
.B telnet
command on its command-line,
.B telnet
executes that command automatically before it enters command mode.
.PP
You can also name a
.I remotehost
and a
.I port
on
.BR telnet 's
command line.
When you do so,
.B telnet
automatically uses its command
.B open
to open a connection with
.I remotehost
via
.IR port .
.PP
Once it has opened a connection with a remote host,
.B telnet
enters input mode.
The input mode entered is either
character-by-character or line-by-line, depending upon
what the remote system supports.
In
.I character-by-character
mode,
.B telnet
immediately sends each character you type to the remote host,
for it to process.
In
.I line-by-line
mode,
.B telnet
echoes all text locally, but does not send anything to the remote host until
you press \*(RT; then it sends the entire line at once.
To turn off local echoing, type the echo character (initially \fB<ctrl-E>\fR).
You would use this to, say, type a password.
.PP
In either mode, if you toggle on the command
.BR localchars ,
.B telnet
locally traps the strings
.BR quit ,
.BR intr ,
and
.BR flush ,
and sends them as protocol sequences to the remote host.
Toggling on the command
.B "autoflush"
tells
.B telnet
to flush all subsequent output to the terminal, until the remote host
acknowledges the
.B TELNET
sequence;
toggling on the command
.B "autosynch"
tells it to flush previous terminal input (in the case of
.B quit
and
.BR intr ).
.PP
While you are connected to a remote host, you can invoke
.BR telnet 's
command mode entered by typing the escape character (initially,
\fB<ctrl-]>\fR).
While you are in command mode,
normal terminal-editing conventions are available.
.SH "Commands"
.B telnet
recognizes the following commands:
.IP "\fB? [\fIcommand\^\fB]\fR"
Print a help message for the given
.B telnet
.IR command .
If you do not name a
.IR command ,
.B telnet
displays a summary of its commands.
.IP \fBclose\fR
Close the
.B telnet
session and return to command mode.
.IP "\fBdisplay [\fIvariable ...\^\fB]\fR"
Display the value of each
.IR variable ,
which has been set or toggled.
.IP "\fBmode \fItype\fR"
Change the mode of the connection to the remote host.
.I type
can be either
.B line
or
.BR character ,
for, respectively, line-by-line or character-by-character mode.
.B telnet
asks
.I remotehost
for permission to enter the mode you request,
then enters it if permission is granted.
.IP "\fBopen \fIremotehost \fB[\fIport\^\fB]\fR"
Open a connection to
.IR remotehost .
If you do not name a
.IR port ,
.B telnet
attempts to contact the server at the default port.
.I remotehost
can be either
.IR remotehost 's
name or its Internet address.
.IP
After
.B telnet
connects to
.IR remotehost ,
it reads file
.B .telnetrc
(in your home directory on your local host),
and executes the commands therein.
This file is described in its own section, below.
.IP \fBoptions\fR
Toggle the display of some internal
.B telnet
protocol processing.
By default, this is toggled off.
.IP \fBquit\fR
Close the
.B telnet
session and exit from
.BR telnet .
When
.B telnet
is in command mode, the end-of-file indicator \fB<ctrl-D>\fR is a synonym for
.BR quit .
.\".IP \fBz\fR
.\"Suspend
.\".BR telnet .
.\"This command only works when you
.\"are using the csh(1).
.IP "\fBsend \fIsequence\fR"
Sends one or more
.IR sequence s
of special characters to
.IR remotehost .
You can use any of the following strings as part of a
.IR sequence ;
each represents a special character, as follows:
.RS
.IP \fB?\fR
Ask
.I remotehost
send information.
This permits you to see the services offered by the
.B telnet
server on
.IR remotehost ,
which may be quite different from those offered by
.B telnet
client on your local host.
.IP \fBao\fR
Send the
.B telnet
AO (abort output) sequence.
This tells
.I remotehost
to flush all output it has queued to send to your terminal.
.IP \fBayt\fR
Send the
.B telnet
AYT (are you there?) sequence.
.I remotehost
may or may not choose to respond.
.IP \fBbrk\fR
Send the TELNET break sequence,
which may mean something to the remote system.
.IP \fBec\fR
Send the
.B telnet
EC (erase character) sequence.
This asks
.I remotehost
to erase the last character entered.
.IP \fBel\fR
Send the
.B telnet
EL (erase line) sequence.
This asks
.I remotehost
to erase the line that you are now entering.
.IP \fBescape\fR
Send the escape character (initially \fB<ctrl-]>\fR).
.IP \fBga\fR
Send the
.B telnet
GA (go ahead) sequence.
In all probability,
this has no significance to the remote system.
.IP \fBip\fR
Send the
.B telnet
IP (interrupt process) sequence.
This tells
.I remotehost
to abort the process it is running.
.IP \fBnop\fR
Send the
.B telnet
NOP (no operation) sequence.
.IP \fBsynch\fR
Send the
.B telnet
SYNCH sequence.
This sequence tells
.I remotehost
to discard all input that it has received but not yet read.
This sequence is sent as TCP urgent data (and may not work if the
remote system is a 4.2 BSD system).
If the command does not work,
.B telnet
may echo a lower-case `r' on your terminal.
.RE
.IP "\fBset \fIvariable value\fR"
Set
.I variable
to
.IR value .
The value
.B off
turns off the function associated with
.IR variable .
.B telnet
recognizes the following
.IR variable s:
.RS
.IP \fBecho\fR
When
.B telnet
is in line-by-line mode, this character toggles
.B telnet
between echoing and not echoing what is typed at the terminal.
By default, this character is
.BR <ctrl-E> .
.IP \fBeof\fR
The end-of-file (EOF) character.
To send EOF to
.I remotehost
when
.B telnet
is in line-by-line mode,
type this character as the first character on a line.
.IP \fBerase\fR
This character sends a
.B telnet
EC sequence to the remote system.
By default, this is your terminal's erase character.
.IP \fBescape\fR
This character puts
.B telnet
into command made.
By default, this character is
.BR <ctrl-]> .
.IP \fBflushoutput\fR
When
.B telnet
is in
.B localchars
mode, this character sends a
.B telnet
AO sequence to
.IR remotehost .
By default, this is the terminal's flush character.
.IP \fBinterrupt\fR
When
.B telnet
is in
.B localchars
mode, this character tells
.B telnet
to send the IP sequence to
.IR remotehost .
By default, this is the terminal's
.B intr
character.
.IP \fBkill\fR
This character sends a
.B telnet
EL sequence to
.IR remotehost
By default, this is the terminal's kill character.
.IP \fBquit\fR
When
.B telnet
is in
.B localchars
mode,
this character sends a
.B telnet
break sequence to
.IR remotehost .
By default, this is the terminal's quit character.
.RE
.IP "\fBtoggle \fIflag ...\fR"
Toggle each
.IR flag ,
each of which controls an aspect of how
.B telnet
responds to events.
The command
.B display
shows the state of every
.IR flag .
.B telnet
recognizes the following
.IR flag s:
.RS
.IP \fBautoflush\fR
If
.B autoflush
and
.B localchars
are both true, then when
.B telnet
recognizes the characters
.BR ao ,
.BR intr ,
and
.B quit
(and transforms them into
.B telnet
escape sequences),
it refuses to display data on the terminal until
.I remotehost
acknowledges that it has processed the escape sequence in question.
By default, this is true if you have not entered the command
.B "stty \-flush" ;
otherwise, by default it is false.
.IP \fBautosynch\fR
If
.B autosynch
and
.B localchars
are both true, then when you type either of the characters
.B intr
or
.BR quit ,
.B telnet
sends the resulting escape sequence followed by the
.B telnet
SYNCH sequence.
This procedure forces
.I remotehost
to throw away all previously typed input until both of the
.B telnet
sequences have been read and acted upon.
By default, this is false.
.IP \fBcrmod\fR
Toggle carriage-return mode.
When enabled,
.B telnet
maps most carriage-return characters from
.I remotehost
into the CR/LF pair.
This does not affect the characters that you type,
only those received from
.IR remotehost .
Note that if
.I remotehost
is alreadying sending CR/LF pair, then this mode will create problems.
By default, this mode is false.
.IP \fBcrmod\fR
Toggle carriage-return mode.
When enabled,
.B telnet
maps most carriage-return characters from
.I remotehost
into the CR/LF pair.
This does not affect the characters that you type,
only those received from
.IR remotehost .
Note that if
.I remotehost
is alreadying sending CR/LF pair, then this mode will create problems.
By default, this mode is false.
.IP \fBdebug\fR
Toggle endpoint-level debugging.
This can be used only by the superuser
.BR root .
By default, this mode is false.
.IP \fBlocalchars\fR
If true,
then
.B telnet
interprets locally the characters
.BR flush ,
.BR interrupt ,
.BR quit ,
.BR erase ,
and
.BR kill ,
and transforms them into the appropriate
.B telnet
control sequences (respectively AO, IP, BRK, EC, and EL).
By default, this is true when
.B telnet
is in line-by-line mode, and false in character-by-character mode.
.IP \fBnetdata\fR
Toggle the display of all network data, in hexadecimal format.
By default, this mode is false.
.SH "\&.telnetrc File"
The file
.B $HOME/.telnetrc
on the local host holds commands that
.B telnet
executes when it first opens a connection with a remote host.
The following describes its layout.
.PP
.B telnet
ignores lines that begin with a pound sign `#'; you can use these as comments.
It also ignores blank lines.
.PP
.B telnet
assumes that a line that does
.I not
begin with whitespace names a remote host.
It then assumes that every line thereafter that begins with whitespace
is a
.B telnet
command that is to be executed when it connects with the remote host in
question.
In this way, you can have different configurations for different remote hosts.
.B telnet
processes the commands just as if you typed them manually at
.B telnet
command prompt.
.SH Files
\fB$HOME/.telnetrc\fR \(em Configuration file for \fBtelnet\fR session
.SH "See Also"
.B
commands,
ftp,
telnetd
.R
.SH Notes
There is no adequate way to deal with flow control.
.PP
Some remote systems require that you turn off
echo manually when in line-by-line mode.
.PP
When in line-by-line mode,
.B telnet
recognizes and sends your terminal's EOF character
when it is the first character on a line.
