Manual Pages for UNIX Darwin command on man zshtcpsys
MyWebUniversity

Manual Pages for UNIX Darwin command on man zshtcpsys

ZSHTCPSYS(1) ZSHTCPSYS(1)

NAME

zshtcpsys - zsh tcp system

DESCRIPTION

A module zzsshh//nneett//ttccpp is provided to provide network I/O over TCP/IP from within the shell; see its description in zshmodules(1) . This manual page describes a function suite based on the module. If the module is installed, the functions are usually installed at the same time, in which case they will be available for autoloading in the default function search path. In addition to the zzsshh//nneett//ttccpp module,

the zzsshh//zzsseelleecctt module is used to implement timeouts on read opera-

tions. For troubleshooting tips, consult the corresponding advice for the zzffttpp functions described in zshftpsys(1) . There are functions corresponding to the basic I/O operations open, close, read and send, named ttccppooppeenn etc., as well as a function

ttccppeexxppeecctt for pattern match analysis of data read as input. The sys-

tem makes it easy to receive data from and send data to multiple named sessions at once. In addition, it can be linked with the shell's line

editor in such a way that input data is automatically shown at the ter-

minal. Other facilities available including logging, filtering and configurable output prompts. To use the system where it is available, it should be enough to

`aauuttoollooaadd -UU ttccppooppeenn' and run ttccppooppeenn as documented below to start a

session. The ttccppooppeenn function will autoload the remaining functions. TTCCPP UUSSEERR FFUUNNCCTTIIOONNSS BBaassiicc II//OO

ttccppooppeenn [[-qqzz]] host port [[ sess ]]

ttccppooppeenn [[-qqzz]] [[ -ss sess || -ll sess,,...... ]] ......

ttccppooppeenn [[-qqzz]] [[-aa fd || -ff fd ]] [[ sess ]]

Open a new session. In the first and simplest form, open a TCP connection to host host at port port; numeric and symbolic forms are understood for both. If sess is given, this becomes the name of the session which can be used to refer to multiple different TCP connections. If sess is not given, the function will invent a numeric name value (note this is not the same as the file descriptor to which the session is attached). It is recommended that session names not include `funny' characters, where funny characters are not

well-defined but certainly do not include alphanumerics or

underscores, and certainly do include whitespace. In the second case, one or more sessions to be opened are given

by name. A single session name is given after -ss and a

comma-separated list after -ll; both options may be repeated as

many times as necessary. The host and port are read from the

file ..zzttccppsseessssiioonnss in the same directory as the user's zsh ini-

tialisation files, i.e. usually the home directory, but $$ZZDDOOTTDDIIRR

if that is set. The file consists of lines each giving a ses-

sion name and the corresponding host and port, in that order (note the session name comes first, not last), separated by whitespace. The third form allows passive and fake TCP connections. If the

option -aa is used, its argument is a file descriptor open for

listening for connections. No function front-end is provided to

open such a file descriptor, but a call to `zzttccpp -ll port' will

create one with the file descriptor stored in the parameter

$$RREEPPLLYY. The listening port can be closed with `zzttccpp -cc fd'. A

call to `ttccppooppeenn -aa fd' will block until a remote TCP connec-

tion is made to port on the local machine. At this point, a

session is created in the usual way and is largely indistin-

guishable from an active connection created with one of the first two forms.

If the option -ff is used, its argument is a file descriptor

which is used directly as if it were a TCP session. How well the remainder of the TCP function system copes with this depends on what actually underlies this file descriptor. A regular file is likely to be unusable; a FIFO (pipe) of some sort will work better, but note that it is not a good idea for two different sessions to attempt to read from the same FIFO at once.

If the option -qq is given with any of the three forms, ttccppooppeenn

will not print informational messages, although it will in any case exit with an appropriate status. If the line editor (zle) is in use, which is typically the case if the shell is interactive, ttccppooppeenn installs a handler inside zzllee which will check for new data at the same time as it checks for keyboard input. This is convenient as the shell consumes no CPU time while waiting; the test is performed by the operating

system. Giving the option -zz to any of the forms of ttccppooppeenn

prevents the handler from being installed, so data must be read explicitly. Note, however, this is not necessary for executing complete sets of send and read commands from a function, as zle is not active at this point. Generally speaking, the handler is only active when the shell is waiting for input at a command prompt or in the vvaarreedd builtin. The option has no effect if zle

is not active; `[[[[ -oo zzllee]]]]' will test for this.

The first session to be opened becomes the current session and

subsequent calls to ttccppooppeenn do not change it. The current ses-

sion is stored in the parameter $$TTCCPPSSEESSSS; see below for more

detail about the parameters used by the system.

ttccppcclloossee [[-qqnn]] [[ -aa || -ll sess,,...... || sess ...... ]]

Close the named sessions, or the current session if none is

given, or all open sessions if -aa is given. The options -ll and

-ss are both handled for consistency with ttccppooppeenn, although the

latter is redundant.

If the session being closed is the current one, $$TTCCPPSSEESSSS is

unset, leaving no current session, even if there are other ses-

sions still open.

If the session was opened with ttccppooppeenn -ff, the file descriptor

is closed so long as it is in the range 0 to 9 accessible

directly from the command line. If the option -nn is given, no

attempt will be made to close file descriptors in this case.

The -nn option is not used for genuine zzttccpp session; the file

descriptors are always closed with the session.

If the option -qq is given, no informational messages will be

printed.

ttccpprreeaadd [[-bbddqq]] [[ -tt TO ]] [[ -TT TO ]]

[[ -aa || -uu fd ...... || -ll sess,,...... || -ss sess ......]]

Perform a read operation on the current session, or on a list of

sessions if any are given with -uu, -ll or -ss, or all open ses-

sions if the option -aa is given. Any of the -uu, -ll or -ss

options may be repeated or mixed together. The -uu option speci-

fies a file descriptor directly (only those managed by this sys-

tem are useful), the other two specify sessions as described for ttccppooppeenn above. The function checks for new data available on all the sessions

listed. Unless the -bb option is given, it will not block wait-

ing for new data. Any one line of data from any of the avail-

able sessions will be read, stored in the parameter $$TTCCPPLLIINNEE,

and displayed to standard output unless $$TTCCPPSSIILLEENNTT contains a

non-empty string. When printed to standard output the string

$$TTCCPPPPRROOMMPPTT will be shown at the start of the line; the default

form for this includes the name of the session being read. See below for more information on these parameters. In this mode, ttccpprreeaadd can be called repeatedly until it returns status 2 which indicates all pending input from all specified sessions has been handled.

With the option -bb, equivalent to an infinite timeout, the func-

tion will block until a line is available to read from one of the specified sessions. However, only a single line is returned.

The option -dd indicates that all pending input should be

drained. In this case ttccpprreeaadd may process multiple lines in

the manner given above; only the last is stored in $$TTCCPPLLIINNEE,

but the complete set is stored in the array $$ttccpplliinneess. This is

cleared at the start of each call to ttccpprreeaadd.

The options -tt and -TT specify a timeout in seconds, which may be

a floating point number for increased accuracy. With -tt the

timeout is applied before each line read. With -TT, the timeout

applies to the overall operation, possibly including multiple

read operations if the option -dd is present; without this

option, there is no distinction between -tt and -TT.

The function does not print informational messages, but if the

option -qq is given, no error message is printed for a non-exis-

tent session. A return value of 2 indicates a timeout or no data to read. Any

other non-zero return value indicates some error condition.

See ttccpplloogg for how to control where data is sent by ttccpprreeaadd.

ttccppsseenndd [[-nnqq]] [[ -ss sess || -ll sess,,...... ]] data ......

ttccppsseenndd [[-nnqq]] -aa data ......

Send the supplied data strings to all the specified sessions in

turn. The underlying operation differs little from a `pprriinntt -rr'

to the session's file descriptor, although it attempts to pre-

vent the shell from dying owing to a SSIIGGPPIIPPEE caused by an attempt to write to a defunct session.

The option -nn prevents ttccppsseenndd from putting a newline at the

end of the data strings. The remaining options all behave as for ttccpprreeaadd. The data arguments are not further processed once they have been

passed to ttccppsseenndd; they are simply passed down to pprriinntt -rr.

If the parameter $$TTCCPPOOUUTTPPUUTT is a non-empty string and logging

is enabled then the data sent to each session will be echoed to

the log file(s) with $$TTCCPPOOUUTTPPUUTT in front where appropriate,

much in the manner of $$TTCCPPPPRROOMMPPTT.

SSeessssiioonn MMaannaaggeemmeenntt

ttccppaalliiaass [[-qq]] alias==sess ......

ttccppaalliiaass [[-qq]] [[ alias ]] ......

ttccppaalliiaass -dd [[-qq]] alias ......

This function is not particularly well tested. The first form creates an alias for a session name; alias can then be used to refer to the existing session sess. As many aliases may be listed as required. The second form lists any aliases specified, or all aliases if none. The third form deletes all the aliases listed. The underlying sessions are not affected.

The option -qq suppresses an inconsistently chosen subset of

error messages.

ttccpplloogg [[-aasscc]] [[ -nn || -NN ]] [[ logfile ]]

With an argument logfile, all future input from ttccpprreeaadd will be

logged to the named file. Unless -aa (append) is given, this

file will first be truncated or created empty. With no argu-

ments, show the current status of logging.

With the option -ss, per-session logging is enabled. Input from

ttccpprreeaadd is output to the file logfile.sess. As the session is automatically discriminated by the filename, the contents are

raw (no $$TTCCPPPPRROOMMPPTT). The option -aa applies as above.

Per-session logging and logging of all data in one file are not

mutually exclusive.

The option -cc closes all logging, both complete and per-session

logs.

The options -nn and -NN respectively turn off or restore output of

data read by ttccpprreeaadd to standard output; hence `ttccpplloogg -ccnn'

turns off all output by ttccpprreeaadd. The function is purely a convenient front end to setting the

parameters $$TTCCPPLLOOGG, $$TTCCPPLLOOGGSSEESSSS, $$TTCCPPSSIILLEENNTT, which are

described below. ttccpprreennaammee old new Rename session old to session new. The old name becomes invalid. ttccppsseessss [[ sess [[ command ...... ]] ]] With no arguments, list all the open sessions and associated file descriptors. The current session is marked with a star. For use in functions, direct access to the parameters

$$ttccppbbyynnaammee, $$ttccppbbyyffdd and $$TTCCPPSSEESSSS is probably more conve-

nient; see below. With a sess argument, set the current session to sess. This is

equivalent to changing $$TTCCPPSSEESSSS directly.

With additional arguments, temporarily set the current session while executing the string ccoommmmaanndd ....... The first argument is

re-evaluated so as to expand aliases etc., but the remaining

arguments are passed through as the appear to ttccppsseessss. The original session is restored when ttccppsseessss exits. AAddvvaanncceedd II//OO

ttccppccoommmmaanndd send-options ...... send-arguments ......

This is a convenient front-end to ttccppsseenndd. All arguments are

passed to ttccppsseenndd, then the function pauses waiting for data.

While data is arriving at least every $$TTCCPPTTIIMMEEOOUUTT (default 0.3)

seconds, data is handled and printed out according to the cur-

rent settings. Status 0 is always returned. This is generally only useful for interactive use, to prevent

the display becoming fragmented by output returned from the con-

nection. Within a programme or function it is generally better to handle reading data by a more explicit method.

ttccppeexxppeecctt [[ -qq ]] [[ -pp var ]] [[ -tt to || -TT TO]]

[[ -aa || -ss sess ...... || -ll sess,,...... ]] pattern ...

Wait for input matching any of the given patterns from any of the specified sessions. Input is ignored until an input line matches one of the given patterns; at this point status zero is

returned, the matching line is stored in $$TTCCPPLLIINNEE, and the full

set of lines read during the call to ttccppeexxppeecctt is stored in the

array $$ttccppeexxppeeccttlliinneess.

Sessions are specified in the same way as ttccpprreeaadd: the default is to use the current session, otherwise the sessions specified

by -aa, -ss, or -ll are used.

Each pattern is a standard zsh extended-globbing pattern; note

that it needs to be quoted to avoid it being expanded immedi-

ately by filename generation. It must match the full line, so to match a substring there must be a `**' at the start and end.

The line matched against includes the $$TTCCPPPPRROOMMPPTT added by

ttccpprreeaadd. It is possible to include the globbing flags `##bb' or

`##mm' in the patterns to make backreferences available in the

parameters $$MMAATTCCHH, $$mmaattcchh, etc., as described in the base zsh

documentation on pattern matching. Unlike ttccpprreeaadd, the default behaviour of ttccppeexxppeecctt is to block indefinitely until the required input is found. This can be

modified by specifying a timeout with -tt or -TT; these function

as in ttccpprreeaadd, specifying a per-read or overall timeout,

respectively, in seconds, as an integer or floating-point num-

ber. As ttccpprreeaadd, the function returns status 2 if a timeout occurs. The function returns as soon as any one of the patterns given match. If the caller needs to know which of the patterns

matched, the option -pp var can be used; on return, $$vvaarr is set

to the number of the pattern using ordinary zsh indexing, i.e.

the first is 1, and so on. Note the absence of a `$$' in front

of var. To avoid clashes, the parameter cannot begin with `eexxppeecctt'.

The option -qq is passed directly down to ttccpprreeaadd.

As all input is done via ttccpprreeaadd, all the usual rules about output of lines read apply. One exception is that the parameter

$$ttccpplliinneess will only reflect the line actually matched by

ttccppeexxppeecctt; use $$ttccppeexxppeeccttlliinneess for the full set of lines read

during the function call. ttccpppprrooxxyy

This is a simple-minded function to accept a TCP connection and

execute a command with I/O redirected to the connection.

Extreme caution should be taken as there is no security whatso-

ever and this can leave your computer open to the world. Ide-

ally, it should only be used behind a firewall.

The first argument is a TCP port on which the function will lis-

ten.

The remaining arguments give a command and its arguments to exe-

cute with standard input, standard output and standard error redirected to the file descriptor on which the TCP session has been accepted. If no command is given, a new zsh is started. This gives everyone on your network direct access to your account, which in many cases will be a bad thing. The command is run in the background, so ttccpppprrooxxyy can then accept new connections. It continues to accept new connections until interrupted.

ttccppssppaamm [[-eerrttvv]] [[ -aa || -ss sess || -ll sess,,...... ]] cmd ......

Execute `cmd ......' for each session in turn. Note this executes the command and arguments; it does not send the command line as

data unless the -tt (transmit) option is given.

The sessions may be selected explicitly with the standard -aa, -ss

or -ll options, or may be chosen implicitly. If none of the

three options is given the rules are: first, if the array

$$ttccppssppaammlliisstt is set, this is taken as the list of sessions,

otherwise all sessions are taken. Second, any sessions given in

the array $$ttccppnnoossppaammlliisstt are removed from the list of ses-

sions.

Normally, any sessions added by the `-aa' flag or when all ses-

sions are chosen implicitly are spammed in alphabetic order;

sessions given by the $$ttccppssppaammlliisstt array or on the command

line are spammed in the order given. The -rr flag reverses the

order however it was arrived it.

The -vv flag specifies that a $$TTCCPPPPRROOMMPPTT will be output before

each session. This is output after any modification to TCPSESS

by the user-defined ttccppoonnssppaamm function described below.

(Obviously that function is able to generate its own output.)

If the option -ee is present, the line given as cmd ... is exe-

cuted using eevvaall, otherwise it is executed without any further processing. ttccppttaallkk

This is a fairly simple-minded attempt to force input to the

line editor to go straight to the default TCPSESSION.

An escape string, $$TTCCPPTTAALLKKEESSCCAAPPEE, default `:', is used to

allow access to normal shell operation. If it is on its own at the start of the line, or followed only by whitespace, the line editor returns to normal operation. Otherwise, the string and any following whitespace are skipped and the remainder of the

line executed as shell input without any change of the line edi-

tor's operating mode. The current implementation is somewhat deficient in terms of use of the command history. For this reason, many users will prefer to use some form of alternative approach for sending data easily to the current session. One simple approach is to alias some

special character (such as `%%') to `ttccppccoommmmaanndd --'.

ttccppwwaaiitt The sole argument is an integer or floating point number which gives the seconds to delay. The shell will do nothing for that period except wait for input on all TCP sessions by calling

ttccpprreeaadd -aa. This is similar to the interactive behaviour at

the command prompt when zle handlers are installed.

``OOnnee-sshhoott'' ffiillee ttrraannssffeerr

ttccppppooiinntt port ttccppsshhoooott host port This pair of functions provide a simple way to transfer a file between two hosts within the shell. Note, however, that bulk data transfer is currently done using ccaatt. ttccppppooiinntt reads any data arriving at port and sends it to standard output; ttccppsshhoooott connects to port on host and sends its standard input. Any unused port may be used; the standard mechanism for picking a

port is to think of a random four-digit number above 1024 until

one works. To transfer a file from host wwooooddccoocckk to host sspprriinnggeess, on sspprriinnggeess: ttccppppooiinntt 88009911 >>oouuttppuuttffiillee and on wwooooddccoocckk: ttccppsshhoooott sspprriinnggeess 88009911 <TTCCPP UUSSEERR-DDEEFFIINNEEDD FFUUNNCCTTIIOONNSS

Certain functions, if defined by the user, will be called by the func-

tion system in certain contexts. This facility depends on the module zzsshh//ppaarraammeetteerr, which is usually available in interactive shells as the completion system depends on it. None of the functions need be defined; they simply provide convenient hooks when necessary. Typically, these are called after the requested action has been taken, so that the various parameters will reflect the new state. ttccppoonnaalliiaass alias fd When an alias is defined, this function will be called with two arguments: the name of the alias, and the file descriptor of the corresponding session. ttccppoonncclloossee sess fd This is called with the name of a session being closed and the file descriptor which corresponded to that session. Both will be invalid by the time the function is called. ttccppoonnooppeenn sess fd This is called after a new session has been defined with the session name and file descriptor as arguments. ttccppoonnrreennaammee oldsess fd newsess This is called after a session has been renamed with the three arguments old session name, file descriptor, new session name. ttccppoonnssppaamm sess command ......

This is called once for each session spammed, just before a com-

mand is executed for a session by ttccppssppaamm. The arguments are the session name followed by the command list to be executed.

If ttccppssppaamm was called with the option -tt, the first command

will be ttccppsseenndd.

This function is called after $$TTCCPPSSEESSSS is set to reflect the

session to be spammed, but before any use of it is made. Hence

it is possible to alter the value of $$TTCCPPSSEESSSS within this func-

tion. For example, the session arguments to ttccppssppaamm could include extra information to be stripped off and processed in ttccppoonnssppaamm.

If the function sets the parameter $$RREEPPLLYY to `ddoonnee', the command

line is not executed; in addition, no prompt is printed for the

-vv option to ttccppssppaamm.

ttccppoonnuunnaalliiaass alias fd This is called with the name of an alias and the corresponding session's file descriptor after an alias has been deleted. TTCCPP UUTTIILLIITTYY FFUUNNCCTTIIOONNSS The following functions are used by the TCP function system but will rarely if ever need to be called directly. ttccppffddhhaannddlleerr This is the function installed by ttccppooppeenn for handling input from within the line editor, if that is required. It is in the

format documented for the builtin `zzllee -FF' in zshzle(1) .

While active, the function sets the parameter TTCCPPHHAANNDDLLEERRAACCTTIIVVEE to 1. This allows shell code called internally (for example, by setting ttccppoonnrreeaadd) to tell if is being called when the shell is otherwise idle at the editor prompt.

ttccppoouuttppuutt [[ -qq ]] -PP prompt -FF fd -SS sess

This function is used for both logging and handling output to

standard output, from within ttccpprreeaadd and (if $$TTCCPPOOUUTTPPUUTT is

set) ttccppsseenndd.

The prompt to use is specified by -PP; the default is the empty

string. It can contain:

%%cc Expands to 1 if the session is the current session, oth-

erwise 0. Used with ternary expresions such as

`%%((cc..-..++))' to output `++' for the current session and `-'

otherwise.

%%ff Replaced by the session's file descriptor.

%%ss Replaced by the session name.

%%%% Replaced by a single `%%'.

The option -qq suppresses output to standard output, but not to

any log files which are configured.

The -SS and -FF options are used to pass in the session name and

file descriptor for possible replacement in the prompt. TTCCPP UUSSEERR PPAARRAAMMEETTEERRSS Parameters follow the usual convention that uppercase is used for

scalars and integers, while lowercase is used for normal and associa-

tive array. It is always safe for user code to read these parameters. Some parameters may also be set; these are noted explicitly. Others are included in this group as they are set by the function system for the user's benefit, i.e. setting them is typically not useful but is benign.

It is often also useful to make settable parameters local to a func-

tion. For example, `llooccaall TTCCPPSSIILLEENNTT==11' specifies that data read dur-

ing the function call will not be printed to standard output, regard-

less of the setting outside the function. Likewise, `llooccaall TTCCPPSSEESSSS==sess' sets a session for the duration of a function, and `llooccaall TTCCPPPPRROOMMPPTT==' specifies that no prompt is used for input during the function. ttccppeexxppeeccttlliinneess Array. The set of lines read during the last call to

ttccppeexxppeecctt, including the last ($$TTCCPPLLIINNEE).

ttccppffiilltteerr Array. May be set directly. A set of extended globbing patterns which, if matched in ttccppoouuttppuutt, will cause the line not to be printed to standard output. The patterns should be defined as described for the arguments to ttccppeexxppeecctt. Output of line to log files is not affected. TTCCPPHHAANNDDLLEERRAACCTTIIVVEE Scalar. Set to 1 within ttccppffddhhaannddlleerr to indicate to functions called recursively that they have been called during an editor session. Otherwise unset. TTCCPPLLIINNEE The last line read by ttccpprreeaadd, and hence also ttccppeexxppeecctt. TTCCPPLLIINNEEFFDD

The file descriptor from which $$TTCCPPLLIINNEE was read.

$${{ttccppbbyyffdd[[$$TTCCPPLLIINNEEFFDD]]}} will give the corresponding session

name. ttccpplliinneess Array. The set of lines read during the last call to ttccpprreeaadd,

including the last ($$TTCCPPLLIINNEE).

TTCCPPLLOOGG May be set directly, although it is also controlled by ttccpplloogg. The name of a file to which output from all sessions will be

sent. The output is proceeded by the usual $$TTCCPPPPRROOMMPPTT. If it

is not an absolute path name, it will follow the user's current directory. TTCCPPLLOOGGSSEESSSS May be set directly, although it is also controlled by ttccpplloogg. The prefix for a set of files to which output from each session separately will be sent; the full filename is

$${{TTCCPPLLOOGGSSEESSSS}}..sess. Output to each file is raw; no prompt is

added. If it is not an absolute path name, it will follow the user's current directory. ttccppnnoossppaammlliisstt Array. May be set directly. See ttccppssppaamm for how this is used. TTCCPPOOUUTTPPUUTT

May be set directly. If a non-empty string, any data sent to a

session by ttccppsseenndd will be logged. This parameter gives the

prompt to be used in a file specified by $$TTCCPPLLOOGG but not in a

file generated from $$TTCCPPLLOOGGSSEESSSS. The prompt string has the

same format as TTCCPPPPRROOMMPPTT and the same rules for its use apply. TTCCPPPPRROOMMPPTT May be set directly. Used as the prefix for data read by ttccpprreeaadd which is printed to standard output or to the log file

given by $$TTCCPPLLOOGG, if any. Any `%%ss', `%%ff' or `%%%%' occurring in

the string will be replaced by the name of the session, the ses-

sion's underlying file descriptor, or a single `%%', respec-

tively. The expression `%%cc' expands to 1 if the session being

read is the current session, else 0; this is most useful in

ternary expressions such as `%%((cc..-..++))' which outputs `++' if the

session is the current one, else `-'.

TTCCPPRREEAADDDDEEBBUUGG

May be set directly. If this has non-zero length, ttccpprreeaadd will

give some limited diagnostics about data being read. TTCCPPSSEECCOONNDDSSSSTTAARRTT This value is created and initialised to zero by tcpopen. The functions ttccpprreeaadd and ttccppeexxppeecctt use the shell's SSEECCOONNDDSS parameter for their own timing purposes. If that parameter is not of floating point type on entry to one of the functions, it will create a local parameter SSEECCOONNDDSS which is floating point and set the parameter TTCCPPSSEECCOONNDDSSSSTTAARRTT to the previous value of

$$SSEECCOONNDDSS. If the parameter is already floating point, it is

used without a local copy being created and TTCCPPSSEECCOONNDDSSSSTTAARRTT is not set. As the global value is zero, the shell elapsed time is

guaranteed to be the sum of $$SSEECCOONNDDSS and $$TTCCPPSSEECCOONNDDSSSSTTAARRTT.

This can be avoided by setting SSEECCOONNDDSS globally to a floating

point value using `ttyyppeesseett -FF SSEECCOONNDDSS'; then the TCP functions

will never make a local copy and never set TTCCPPSSEECCOONNDDSSSSTTAARRTT to

a non-zero value.

TTCCPPSSEESSSS May be set directly. The current session; must refer to one of the sessions established by ttccppooppeenn. TTCCPPSSIILLEENNTT May be set directly, although it is also controlled by ttccpplloogg.

If of non-zero length, data read by ttccpprreeaadd will not be written

to standard output, though may still be written to a log file. ttccppssppaammlliisstt

Array. May be set directly. See the description of the func-

tion ttccppssppaamm for how this is used. TTCCPPTTAALLKKEESSCCAAPPEE May be set directly. See the description of the function ttccppttaallkk for how this is used. TTCCPPTTIIMMEEOOUUTT

May be set directly. Currently this is only used by the func-

tion ttccppccoommmmaanndd, see above.

TTCCPP UUSSEERR-DDEEFFIINNEEDD PPAARRAAMMEETTEERRSS

The following parameters are not set by the function system, but have a special effect if set by the user. ttccppoonnrreeaadd This should be an associative array; if it is not, the behaviour is undefined. Each key is the name of a shell function or other command, and the corresponding value is a shell pattern (using EEXXTTEENNDDEEDDGGLLOOBB). Every line read from a TCP session directly or indirectly using ttccpprreeaadd (which includes lines read by ttccppeexxppeecctt) is compared against the pattern. If the line

matches, the command given in the key is called with two argu-

ments: the name of the session from which the line was read, and the line itself.

If any function called to handle a line returns a non-zero sta-

tus, the line is not output. Thus a ttccppoonnrreeaadd handler con-

taining only the instruction `rreettuurrnn 11' can be used to suppress output of particular lines (see, however, ttccppffiilltteerr above). However, the line is still stored in TTCCPPLLIINNEE and ttccpplliinneess; this occurs after all ttccppoonnrreeaadd processing. TTCCPP UUTTIILLIITTYY PPAARRAAMMEETTEERRSS These parameters are controlled by the function system; they may be read directly, but should not usually be set by user code. ttccppaalliiaasseess

Associative array. The keys are the names of sessions estab-

lished with ttccppooppeenn; each value is a space-separated list of

aliases which refer to that session. ttccppbbyyffdd Associative array. The keys are session file descriptors; each value is the name of that session. ttccppbbyynnaammee Associative array. The keys are the names of sessions; each value is the file descriptor associated with that session. TTCCPP EEXXAAMMPPLLEESS Here is a trivial example using a remote calculator. TO create a calculator server on port 7337 (see the ddcc manual page for quite how infuriating the underlying command is): ttccpppprrooxxyy 77333377 ddcc To connect to this from the same host with a session also named `ddcc': ttccppooppeenn llooccaallhhoosstt 77333377 ddcc

To send a command to the remote session and wait a short while for out-

put (assuming ddcc is the current session): ttccppccoommmmaanndd 22 44 ++ pp To close the session: ttccppcclloossee The ttccpppprrooxxyy needs to be killed to be stopped. Note this will not usually kill any connections which have already been accepted, and also that the port is not immediately available for reuse. The following chunk of code puts a list of sessions into an xterm header, with the current session followed by a star.

pprriinntt -nn ""\\003333]]22;;TTCCPP::"" $${{((kk))ttccppbbyynnaammee:://$$TTCCPPSSEESSSS//$$TTCCPPSSEESSSS\\**}} ""\\aa""

TCP BUGS

The function ttccpprreeaadd uses the shell's normal rreeaadd builtin. As this

reads a complete line at once, data arriving without a terminating new-

line can cause the function to block indefinitely. Though the function suite works well for interactive use and for data arriving in small amounts, the performance when large amounts of data are being exchanged is likely to be extremely poor. zsh 4.2.3 January 13, 2005 ZSHTCPSYS(1)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™