[Previous] [Contents] [Index] [Next]

telnet

User interface to the TELNET protocol (UNIX)

Syntax:

telnet [-8] [-c] [-d] [-E] [-e escape_char] 
       [-L] [-N] [-n tracefile] [-P policy] 
       [-S tos] [host [port]]

Options:

-8
Allow an eight-bit input data path at all times. Without this option, parity bits are stripped whenever the remote side's stop and start characters are ^S and ^Q.
-c
Disables the reading of the user's .telnetrc file. (See the skiprc argument of the toggle telnet command, below.)
-d
Set the initial value of the debug toggle to TRUE.
-E
Disable the telnet escape character.
-e escape_char
Set the initial telnet escape character to escape_char (default is Ctrl-]). This character lets you switch to telnet's command mode.
-L
Specifies an 8-bit data path on output. This causes the BINARY option to be negotiated on output.
-N
Numeric host address. Prevents look up of a symbolic name when the destination host is given as an IP address.
-n tracefile
Record trace information in the specified file. See the set tracefile command, below.
-P policy
Use the IPsec policy specification string policy for the connections. For details of the IPsec policy control, see the Library Reference.
-S tos
Sets the IP type-of-service (TOS) option for the telnet connection to the value tos, which can be a numeric TOS value or, on systems that support it, a symbolic TOS name found in the /etc/iptos file.
host
The official name, an alias, or the Internet address of a remote host.
port
A port number (address of an application). If a number isn't specified, the default telnet port is used.

Description:

Use the telnet command to communicate with another host via the TELNET protocol. If you invoke telnet without a host argument, it enters command mode and displays this prompt:

telnet>

In command mode, telnet accepts and executes the commands listed in "Telnet commands," below.

If you invoke telnet with a host argument, it opens a connection to the named host (i.e. it performs an open command).

If LINEMODE is enabled, character processing is done on the local system, under the control of the remote system. When input editing or character echoing is to be disabled, the remote system relays that information. The remote system also relays changes to any special characters that happen on the remote system, so that they can take effect on the local system.

In "character-at-a-time" mode, most text that's typed is immediately sent to the remote host for processing.

In "old-line-by-line" mode, all text is echoed locally, and (in most cases) only completed lines are sent to the remote host. You can use the "local echo character" (initially Ctrl-E) to turn off and on the local echo (you use this mostly to enter passwords without echoing).

If the LINEMODE option is enabled, or if the localchars toggle is TRUE (the default for "old-line-by-line"), your quit, intr, and flush characters are trapped locally and sent as TELNET protocol sequences to the remote side.

If LINEMODE has ever been enabled, then your susp and eof are also sent as TELNET protocol sequences, and quit is sent as a TELNET ABORT instead of as a BREAK. There are options (see toggle autoflush and toggle autosynch below) that cause this action to flush subsequent terminal output (until the remote host acknowledges the TELNET sequence) and to flush previous terminal input (in the case of quit and intr).

While you're connected to a remote host, you can enter telnet's command mode by entering the telnet escape sequence (initially Ctrl-]). The normal terminal editing conventions are available in command mode.

Telnet commands:

In the following commands, you need to type only enough of each command to uniquely identify it; this is also true for arguments to the mode, set, toggle, unset, environ, and display commands.

close
Close a TELNET session and return to command mode.
display argument...
Display all, or some, of the set and toggle values (see below).
mode type
The type argument can have one of several values, depending on the state of the TELNET session. The remote host is asked for permission to go into the requested mode. If the remote host can enter that mode, the mode is entered.
character
Disable the TELNET LINEMODE option; if the remote side doesn't understand the LINEMODE option, enter character-at-a-time mode instead.
line
Enable the TELNET LINEMODE option; if the remote side doesn't understand the LINEMODE option, attempt to enter old-line-by-line mode instead.
[-]isig
Attempt to enable (disable) the TRAPSIG mode of the LINEMODE option. LINEMODE must be enabled.
[-]edit
Attempt to enable (disable) the EDIT mode of the LINEMODE option. LINEMODE must be enabled.
[-]softtabs
Attempt to enable (disable) the SOFT_TAB mode of the LINEMODE option. LINEMODE must be enabled.
[-]litecho
Attempt to enable (disable) the LIT_ECHO mode of the LINEMODE option. LINEMODE must be enabled.
?
Print help information for the mode command.
open host [[-l] user] [-port]
Open a connection to the named host. If no port number is specified, telnet tries to contact a TELNET server at the default port. The host may be specified either as a hostname (see the /etc/hosts file) or as an Internet address specified in the "dot notation" (see the Internet address manipulation routines, inet*() in the Library Reference).

With the -l option, you can specify the username to be passed to the remote system via the ENVIRON option.

When connecting to a nonstandard port, telnet omits any automatic initiation of TELNET options. When port is preceded by a minus sign, the initial option negotiation is done. Once telnet establishes a connection, it opens the .telnetrc file that's in your home directory.

In this file, lines beginning with a # are comments. Blank lines are ignored. Lines that begin without whitespace are the start of a machine entry. The first thing on the line is the name of the machine that's being connected to. The rest of the line and the successive lines that begin with whitespace are assumed to be telnet commands; they're processed as if you had typed them manually at the telnet> command prompt.

quit
Close any open TELNET session and exit telnet. An end-of-file (in command mode) also closes a session and exits.
send arguments
Send one or more special character sequences to the remote host. You can specify the following arguments (more than one argument may be specified at a time):
abort
Send the TELNET ABORT (Abort processes) sequence.
ao
Send the TELNET AO (Abort Output) sequence, which should cause the remote system to flush all its output to the user's terminal.
ayt
Send the TELNET AYT (Are You There) sequence, to which the remote system may or may not choose to respond.
brk
Send the TELNET BRK (Break) sequence, which may have significance to the remote system.
ec
Send the TELNET EC (Erase Character) sequence, which should cause the remote system to erase the last character entered.
el
Send the TELNET EL (Erase Line) sequence, which should cause the remote system to erase the line currently being entered.
eof
Send the TELNET EOF (end-of-file) sequence.
eor
Send the TELNET EOR (end-of-record) sequence.
escape
Send the current telnet escape character (initially Ctrl-]).
ga
Send the TELNET GA (Go Ahead) sequence, which likely has no significance to the remote system.
getstatus
If the remote side supports the TELNET STATUS command, send the subnegotiation to request that the server send its current option status.
ip
Send the TELNET IP (Interrupt Process) sequence, which should cause the remote system to abort the currently running process.
nop
Send the TELNET NOP (No OPeration) sequence.
susp
Send the TELNET SUSP (SUSPend process) sequence.
synch
Send the TELNET SYNCH sequence. This sequence causes the remote system to discard all previously typed (but not yet read) input. This sequence is sent as TCP urgent data -- it might not work if the remote system is a 4.2BSD system. If it doesn't work, a lowercase "r" might be echoed on the terminal.
?
Print help information for the send command.
set argument value
unset argument value
The set command sets any one of a number of telnet variables to a specific value or to TRUE. The special value off turns off the function associated with the variable -- it's equivalent to using the unset command. The unset command disables or sets to FALSE any of the specified functions.

You can query the values of variables with the display command.

The telnet variables that can be set or unset, but not toggled, are listed here. Note that you also explicitly set or unset any of the toggle command's variables.

ayt
If telnet is in localchars mode, or LINEMODE is enabled, and the status character is typed, a TELNET AYT sequence is sent to the remote host. The initial value for the Are You There character is the terminal's status character.
echo
In old-line-by-line mode, this value (initially Ctrl-E) toggles between doing local echoing of entered characters (for normal processing) and it (e.g. for entering a password).
eof
If telnet is operating in LINEMODE or old-line-by-line mode, this character is sent to the remote system if entered as the first character on a line. The initial value of the eof character is the terminal's EOF character.
erase
If telnet is in localchars mode (see toggle localchars below) and in character-at-a-time mode, then when this character is typed, a TELNET EC sequence (see send ec above) is sent to the remote system. The initial value for the erase character is the terminal's erase character.
escape
This is the telnet escape character; entering it switches you to telnet's command mode when telnet is connected to a remote system. (Initially, the character is Ctrl-] to switch).
flushoutput
If telnet is in localchars mode (see toggle localchars below) and the flushoutput character is typed, a TELNET AO sequence (see send ao above) is sent to the remote host. The initial value for the flush character is the terminal's flush character.
forw1 or forw2
If telnet is operating in LINEMODE, these are the characters that, when typed, cause partial lines to be forwarded to the remote system. The initial value for the forwarding characters are taken from the terminal's eol and eol2 characters.
interrupt
If telnet is in localchars mode (see toggle localchars below) and the interrupt character is typed, a TELNET IP sequence (see send ip above) is sent to the remote host. The initial value for the interrupt character is the terminal's intr character.
kill
If telnet is in localchars mode (see toggle localchars below) and in character-at-a-time mode, then when this character is typed, a TELNET EL sequence (see send el above) is sent to the remote system. The initial value for the kill character is the terminal's kill character.
lnext
If telnet is in LINEMODE or old-line-by-line mode, then this character is the terminal's lnext character. The initial value for the lnext character is the terminal's lnext character.
quit
If telnet is in localchars mode (see toggle localchars below) and the quit character is typed, a TELNET BRK sequence (see send brk above) is sent to the remote host. The initial value for the quit character is the terminal's quit character.
reprint
If telnet is in LINEMODE or old-line-by-line mode, then this character is the terminal's reprint character. The initial value for the reprint character is the terminal's reprint character.
start
If the TELNET TOGGLE-FLOW-CONTROL option has been enabled, then this character is the terminal's start character. The initial value for the kill character is the terminal's start character.
stop
If the TELNET TOGGLE-FLOW-CONTROL option has been enabled, then this character is the terminal's stop character. The initial value for the kill character is the terminal's stop character.
susp
If telnet is in localchars mode, or if LINEMODE is enabled, and the suspend character is typed, a TELNET SUSP sequence (see send susp above) is sent to the remote host. The initial value for the suspend character is the terminal's suspend character.
tracefile
This the file to which the output is written (when netdata or option tracing is TRUE). If it's set to -, tracing information is written to standard output (the default).
worderase
If telnet is operating in LINEMODE or old-line-by-line mode, then this character is the terminal's word-erase character. The initial value for the word-erase character is the terminal's word-erase character.
?
Display the legal set (unset) commands.
environ argument...
The environ command manipulates the variables that may be sent through the TELNET ENVIRON option. The initial set of variables is taken from the user's environment; only the DISPLAY and PRINTER environment variables are exported by default. Valid arguments are:
define variable value
Define this variable to have this value. Any variables defined by this command aren't automatically exported. To include tabs and spaces in value, enclose it in single or double quotes.
send variable
Send variable to the remote site.
undefine variable
Remove variable from the list of environment variables.
export variable
Mark variable to be exported to the remote side.
unexport variable
Mark variable not to be exported unless explicitly asked for by the remote side.
list
List the current set of environment variables. Those marked with a * are sent automatically; other variables are sent only if explicitly requested.
?
Print help information for the environ command.
toggle flag...
Toggle between TRUE and FALSE various flags that control how telnet responds to events. You can explicitly set these flags to TRUE or FALSE with the set and unset commands listed above. To query the state of these flags, use the display command. Note that you can specify more than one flag.

Valid arguments are:

autoflush
If autoflush and localchars are both TRUE, and the ao or quit characters are recognized (and transformed into TELNET sequences; see set above for details), refuse to display any data on the user's terminal until the remote system acknowledges (via a TELNET TIMING MARK option) that it has processed those TELNET sequences. If the terminal user hasn't done an stty noflsh, the initial value for this toggle is TRUE; otherwise it's FALSE. See stty.
autosynch
If autosynch and localchars are both TRUE, and either the intr or quit character is typed (see set above), send the resulting TELNET sequence and follow it with the TELNET SYNCH sequence. This procedure should cause the remote system to begin throwing away all previously typed input until both of the TELNET sequences have been read and acted upon. The initial value of this toggle is FALSE.
binary
Enable or disable the TELNET BINARY option on both input and output.
inbinary
Enable or disable the TELNET BINARY option on input only.
outbinary
Enable or disable the TELNET BINARY option on output only.
crlf
If this is TRUE, send carriage returns as CR LF. If this is FALSE, send carriage returns as CR NUL. The initial value for this toggle is FALSE.
crmod
Toggle carriage-return mode. When this mode is enabled, most carriage-return characters received from the remote host are mapped into a carriage return followed by a line feed. This mode doesn't affect characters you type, only those received from the remote host. This mode is useful only if the remote host sends only carriage returns and never sends line feeds. The initial value for this toggle is FALSE.
debug
Toggle socket-level debugging (useful only to the superuser). The initial value for this toggle is FALSE.
localchars
If this is TRUE, then the flush, interrupt, quit, erase, and kill characters (see set above) are recognized locally, and should be transformed into appropriate TELNET control sequences (respectively ao, ip, brk, ec, and el; see send above). The initial value for this toggle is TRUE in old-line-by-line mode, and FALSE in character-at-a-time mode. When the LINEMODE option is enabled, the value of localchars is ignored and assumed to be always TRUE. If LINEMODE has ever been enabled, then quit is sent as abort, and eof and susp are sent as eof and susp (see send above).
netdata
Toggle the display of all network data (in hex format). The initial value for this toggle is FALSE.
options
Toggle the display of some internal telnet protocol processing (having to do with TELNET options). The initial value for this toggle is FALSE.
prettydump
If the netdata and prettydump toggles are both enabled, the output from the netdata command is formatted in a more user-readable format. Spaces are put between each character in the output, and the beginning of any TELNET escape sequence is preceded by a * to aid in locating it.
skiprc
When the skiprc toggle is TRUE, telnet skips the reading of the .telnetrc file in the users home directory when connections are opened. The initial value for this toggle is FALSE.
termdata
Toggles the display of all terminal data (in hexadecimal format). The initial value for this toggle is FALSE.
?
Display the legal toggle commands.
z
Suspend telnet. This command works only if you're using csh.
! [command]
Execute a single command in a subshell on the local system. If command is omitted, an interactive subshell is invoked.
status
Show the current status of telnet. This includes the peer you're connected to as well as the current mode.
? [command]
Get help. With no arguments, telnet prints a help summary. If a command is specified, telnet prints the help for that command.

Files:

$HOME/.telnetrc
User-customized startup values for telnet.

The telnet utility requires the libsocket.so shared library.

Environment variables:

The telnet utility uses at least the HOME, SHELL, DISPLAY, and TERM environment variables. The environment variables may be propagated to the other side via the TELNET ENVIRON option.

License:

This utility is based on copyright software of the Regents of the University of California; for the copyright notice, see telnet in the appendix Third-Party Copyright Notices.

Caveats:

On some remote systems, you have to turn echo off manually when you're in old-line-by-line mode.

In old-line-by-line mode or LINEMODE, the terminal's EOF character is recognized (and sent to the remote system) only when it's the first character on a line.

See also:

rlogin, rsh, telnetd

RFC 854


[Previous] [Contents] [Index] [Next]