sympathy(1)
β¨ NAME β¨
sympathy β client/server terminal emulator with logging π
So like, this is the sympathy(1) page, filed under USER COMMANDS, and bestie, buckle up because she does a LOT.
πΈ SYNOPSIS πΈ
sympathy -t [ terminal_options ] [ display_options ]
sympathy -s [ terminal_options ] [ server_options ]
sympathy [ -c -s ] [ terminal_options ] [ server_options ] [ client_options ] [ display_options ]
sympathy -c [ client_options ] [ display_options ]
sympathy -r id [ client_options ] [ display_options ]
sympathy -C -d serialdev
sympathy -ls
sympathy -v
π¦ DESCRIPTION π¦
Okay so sympathy is the glow-up replacement for screen(1), minicom(1) and consolidate(1). She's a VT52/VT100/ANSI terminal emulator with some special features, iykyk.
In normal use, sympathy sits between a terminal device (a serial port or a pseudo-tty) and your usual everyday terminal emulator (think xterm(1), that one). What she does is render the data coming off the terminal device into an internal frame buffer, and then she expresses whatever changed in that frame buffer to the outer terminal emulator using a small subset of ANSI escape codes. And ngl, she's always valid about it: sympathy always generates valid escape codes to the outer terminal, and she'll reset the state of her internal terminal emulator whenever she detects receive errors on the terminal device. No cap. π
Here's the part that's genuinely iconic: sympathy, unlike screen(1), takes actual care to preserve the scroll-back features of the outer terminal emulator. Lines that scroll off the top of the internal frame buffer get scrolled off the top of the outer terminal emulator too. And when you're in client/server mode, some history gets added to the outer terminal emulator the moment the client connects. β¨
Sympathy also supports automatic baud-rate detection and some truly advanced logging features. She logs whenever any of the modem control lines change state, logs receive errors, and logs the contents of any line on the frame buffer as the cursor moves off it. Obsessed, frankly. π
π OPTIONS π
π major mode options:
-Cβ clear lock files: sympathy will remove inactive lockfiles for the specified serial device, and then exit.-cor-r idβ act as client only: sympathy connects to a sympathy server process and injects the history into the outer terminal emulator, and connects you with the terminal device. One server process can support multiple client processes, she's generous like that. This mode can also be used to get a dump of the current screen in HTML format (see the-Hoption), to inject key-presses (see-I), or to allow control via a dumb terminal (see-N). The-roption connects to a server process socket called id, or if id is an integer host-name.id, which mimics the behaviour of screen(1). Sympathy searches for the socket in the following directories:~/.sympathy,~/sympathy,/etc/sympathy,/var/sympathy. With the-coption the socket must be specified with the-koption.[ -c -s ]β act as both client and server: sympathy forks. The child process becomes a server, and the original process becomes a client which then connects to the server. This is the default major mode if no other one is specified. And since the default terminal device is a pseudo-tty, running sympathy with no arguments will start a new shell in a daemonised process and connect to it as a client from the original process, mimicking the behaviour of screen(1). Main character energy fr fr.-lor-lsβ show active sockets: sympathy will show active sockets, ones to which a call to connect(2) succeeds, in~/.sympathy. If the socket name begins with the host-name of the machine, and the call to connect(2) fails, then the socket will be unlinked.-sβ act as server only: sympathy opens the terminal device and renders into an internal frame buffer, listens for clients on the socket, and logs activity. By default the server will fork into a daemon process, but you can force it to remain in the foreground with the-Foption.-tβ act as terminal emulator only: sympathy opens the terminal device and outputs into the outer terminal emulator. When sympathy exits the device is closed and no process remains. In this mode sympathy behaves like a traditional terminal emulator such as cu(1) or minicom(1).-vβ show current version: sympathy will print the version number of the code it was compiled from.-hβ show help: sympathy will show brief usage instructions.
π terminal_options:
-d serialdevβ connect to terminal device serialdev, eg/dev/ttyS0. By default sympathy doesn't lock the terminal device, but she checks periodically for lock files belonging to other processes. If sympathy detects another lock file, she displaysLockedin the status line and refuses I/O on the device until that lock file is removed or becomes invalid. To lock the device, use the-Koption. Sympathy will in addition check that the name of the device does not occur in/proc/cmdlineas an argument to theconsolekernel parameter. Heads up: the-doption is incompatible with the-poption.-pβ connect to a pseudo-tty instead of a terminal device, and fork a login shell in it. The-poption is incompatible with the-doption. This is the default terminal device if none is specified. The first non-option command line argument is considered to be the binary to run in the pseudo-tty, and subsequent arguments are parsed to that binary. The current value ofPATHis searched for the binary if it does not start with/. If no binary is specified then/bin/shis called withargv[0]set to-.-Kβ lock the terminal device specified in the-doption. Sympathy generates lock files in a staggering variety of formats and places. For locks based on the name of the device, sympathy generates lock files for all devices with the same major and minor in/dev,/dev/usband/dev/tts, it uses both normal and lower case, and it replaces occurrences of/in the device name with both.and_. Sympathy also generates locks based on the device major and minor numbers, and for all lock file names she generates them in any of the following directories that are writable:/var/lock/uucp,/var/spool/lock,/var/spool/uucp,/etc/locks,/usr/spool/uucp,/var/spool/locks,/usr/spool/lock,/usr/spool/locks,/usr/spool/uucp/LCK,/var/lock. Lock files are assumed to be in HDB format.-b baud-rateβ set the baud-rate of the terminal device specified in the-dto baud-rate; if it's omitted, the current baud-rate of the serial port will be used.-fβ turn on flow control on the terminal device. This option addsCRTSCTSto sympathy's defaultc_cflagsofCS8|CREAD|CLOCAL.-L logfileβ log activity to the file logfile. If logfile is-then log to stdout. Just so you know, logging to stdout only makes sense with the-Fserver_option. Sympathy will also close and reopen her log file when she receives aSIGHUP, which with the-Pallows the use of logrotate(8). π«Ά-P pidfileβ write the pid of the server/terminal process to pidfile, which is removed on clean exit.-Rβ rotate log files. When the log-file specified with the-Loption grows large, sympathy will rotate it and compress old log-files.-w width[xheight]β set the initial size of the terminal emulator's frame buffer to be width columns by height rows. If height is omitted it defaults to24, and the default width is80. These values may be overridden later by terminal escape sequences. If-pis also specified the pseudo-tty will have its window size set to match.
π display_options:
-uβ attempt to render Unicode characters in the internal frame buffer to the outer terminal emulator by using ISO-2202 sequences. Sympathy currently only checks to see if an appropriate character appears in the VT102 US character set, or in the VT102special characters and line drawingcharacter set. If the character appears in neither of these then it will be rendered on the outer terminal emulator as a?.-Hβ render the current state of the internal frame buffer to stdout as HTML, then quit.-Nβ don't render the internal frame buffer using ANSI characters, but instead write characters that would be written to the screen to stdout. Take characters from stdin and send them to the device. This feature is useful when you wish to use sympathy in conjunction with programs like expect(1).-Bβ write the actual bytes read from the device to the logfile, rather than the rendered version.
π§ client_options:
-k socketβ set the name in the file-system of the socket to which sympathy should connect. This option is mandatory unless the-sor-roptions have also been given. If-sis given then it will default to the socket which the forked server process opens. See the discussion of the-roption above for information on how sympathy chooses a socket name if-ris specified.-I stringβ inject string to the device as if it had been typed at the keyboard. Each character in the string is treated as a key-press. Sympathy recognizes various common escapes for control characters. Other keys, for example the arrow keys, are mapped to character codes between128and255, seesrc/keys.hfor details.
β server_options:
-Fβ tells the sympathy server process not to become a daemon but to remain in the foreground. This option is incompatible with the-c -smajor mode.-k socketβ set the name in the file-system of the socket on which sympathy should listen for clients. If this option is omitted sympathy will create a socket in~/.sympathy, creating that directory if necessary, and named host-name.pid where pid is the process id of the sympathy process that created the socket.-n nlinesβ sets the number of lines of history that the server process stores to nlines. When a client connects, nlines of history are injected into the outer terminal emulator so that they can be seen when scrolling back. By default the server stores200lines of history.-Sβ tells the sympathy server process to log errors to syslog.
bestie there is so much more coming, this was just part one π
π OPERATION π
When sympathy is relaying data to the outer terminal emulator, a reverse video status line will be visible at the bottom of the screen. It's giving dashboard. It's giving β¨at a glanceβ¨.
That status line shows pertinent information, bestie. The first item on the line reminds you what the current escape character is, the second indicates the terminal device to which sympathy is connected, and the third shows the current baud-rate. Iconic trio, honestly.
Other messages that can show up:
- Flow β indicates that RTS/CTS flow control is in operation on the terminal device.
- RTS β indicates that the terminal device is asserting the RTS line, which means the local system is ready to accept data from the remote system. > Heads up: if RTS/CTS flow control is in operation, then the operating system or hardware may de-assert RTS even if RTS is shown. See the section on SERIAL PORT THEORY for more info.
- CTS β indicates that the terminal device has detected that the local system's CTS line is being asserted, indicating that the remote system is ready to receive data from the local system. See the section on SERIAL PORT THEORY for more info.
- DTR β indicates that the terminal device is asserting the DTR line, indicating that the local system would like the local DCE to establish a connection to the remote DCE. See the section on SERIAL PORT THEORY for more info.
- DSR β indicates that the terminal device has detected that the local system's DSR line is being asserted, indicating that the local DCE is ready. See the section on SERIAL PORT THEORY for more info.
- CD β indicates that the terminal device has detected that the local system's CD line is being asserted, indicating that the local DCE has a connection to the remote DCE. See the section on SERIAL PORT THEORY for more info.
- RI β indicates that the terminal device has detected that the local system's RI line is being asserted, indicating that the DCE has detected a ringing signal or incoming connexion.
n clientsβ shows the number of connected client processes. In the-tmajor mode, this will always be zero. π- Locked β the terminal device was opened without the
-Kflag and another process is currently using it. I/O to the device is currently suspended until the process dies or removes its lock file. π n errsβ indicates the number of frames received by the terminal device with errors (indicating the wrong parity, baud-rate or framing). The count resets if no errors are detected by the device for 10 seconds.try higherβ Sympathy thinks you have set the wrong baud-rate and is unable to determine the correct one, because the current baud-rate is lower than the correct baud-rate. Use thebaudcommand to set a higher baud-rate (eg115200) and sympathy will try again. π«Άtry ratebβ Sympathy thinks that you have set the wrong baud-rate and thinks that the correct baud-rate is rate. Use thebaudcommand to change the current baud-rate.
π COMMANDS π
Commands are entered by sending the escape character, ascii(7) STX, from the outer terminal emulator (usually by pressing CTRL-B), typing the command and pressing return. Whilst the command is entered the status line changes to : and rudimentary line editing is available. Ngl, it's a whole vibe.
Whilst the command is entered the cursor does not move but remains where the terminal emulator has placed it. And if you press the escape character whilst in command mode, it will send the escape character to the terminal and cancel command mode. Escape-ception.
Valid commands are:
ansiβ switch from VT102 behaviour to ANSI behaviour. The most noticeable difference is the so-calledxnglitch.noansiβ switch from ANSI behaviour to VT102 behaviour.baud nnnnβ set the current baud-rate to nnnn.breakβ send the break signal by asserting the TX line for longer than a frame period.flowβ enable RTS/CTS flow control.noflowβ disable RTS/CTS flow control.hangupβ de-assert DTR for one second.width nnβ set the current width of the screen to nn, and reset the terminal emulator.height nnβ set the current height of the screen to nn, and reset the terminal emulator.resetβ reset the terminal emulator.expandβ expand the size of the screen to fit the size of the current outer terminal emulator window.quitβ exit this instance ofsympathy(disconnect from the server if present).
π CHARACTER ENCODINGS π
For characters between 32 and 126, sympathy interprets them as would a VT102 terminal, by following the subset of ISO-2202 that the VT102 supports.
Characters 128 thru 255 are assumed to be in UTF-8(7). If, however, the UTF-8 is invalid, they will instead be interpreted as characters from ISO_8859-1(7).
Character 155 (0x9b), when not part of a valid UTF-8 sequence, will be interpreted as the one byte CSI character.
For the outer terminal emulator, sympathy by default issues the ESC % G sequence to select UTF-8 mode and emits valid UTF-8. If the outer terminal does not, however, support UTF-8, use the -u switch to force sympathy to use the VT102 subset of ISO-2202. β¨
π LOG FILES π
Log files are made exclusively in the UTF-8 encoding. Each line in the log file starts with the date and time at which the entry was made β for example:
Feb 27 23:24:42.509440
Sympathy logs a line to the file whenever the cursor leaves the line. Additionally, sympathy:
- logs certain other events to the file:
- serial port parameter changes: baud-rate and flow control.
- serial port control line state changes.
- serial port line discipline errors.
- serial port errors.
- suggested baud rates and bit frequency analyses.
- transmission of breaks.
- sending of the hangup signal (dropping the DTR line).
- unknown or un-handled messages sent on the socket.
- connexion and disconnexion of clients.
- reception of
SIGHUP. - invalid UTF-8 sequences.
- terminal size changes.
- un-handled terminal command sequences.
The log file is rotated when it gets too large if the -R option is specified, and the log file is re-opened on receipt of a SIGHUP, which β together with the -P β allows the use of a program such as logrotate(8). Chef's kiss, truly. π
π AUTOMATIC BAUD RATE ALGORITHM π
If sympathy detects a framing error on the serial port, it displays the count of errors on the status line, and logs the error.
<tty reports error: \377 \000 \000>
The count is reset to zero after ten seconds have elapsed during which no errors have occurred.
Sympathy looks at bit patterns of the characters received, and measures the length (in units of the receiving UART's bit period) of any runs of '1's delimited by '0's and vice-versa. It then calculates the statistics on the length of these runs, and logs these.
<tty_bit_analyse: 0000000001 [0,0,0,0,0,0,110,0,0,80]>
For a typical stream of ASCII data, the most common run length will be the correct bit period. Sympathy uses this, together with the current bit period, to calculate the most probable correct baud-rate, which is displayed in the status line, and logged.
If the correct baudirate is higher than the current baud-rate, then the most common bit frequency will be '0' or '1' and the correct baud-rate cannot be determined. In this case sympathy will display and log the message 'try higher'.
<tty_analyse: 80 errors, current rate 115200b, suggest
19200b>
The algorithm only works well if the data stream is normal. If the data stream is generated by the reception, at the wrong baud-rate, of characters emitted by sympathy, then the algorithm will be biased towards suggesting that the baud-rate is too low. Noise on the line will also result in sympathy concluding that the baud-rate is too low. So likeβ¦ don't trust it blindly, bestie. π
β SIGNALS β
Sympathy reacts to a set of signals. You can use the -P option to easily determine the PID of the sympathy process to which you would like to send a signal.
SIGINTβ Sympathy will immediately try to restore the outer terminal emulator to its original state and then exit.SIGHUPβ Sympathy will close and reopen the log-file specified with the-Loption, which allows the use of programs likelogrotate(8).SIGWINCHβ Sympathy will redraw the display in the outer terminal emulator so that it will fit within the new display size.SIGCHLDβ Sympathy will wait for children if some were born (for example from compressing rotated logs).
π§ ENVIRONMENT π§
sympathyuses theHOMEenvironment variable to determine the default location for sockets.sympathysets the value ofTERMin pseudo-ttys spawned using the-pargument toxterm.- Sympathy will use
CSI ] 0 ;to set the window title to the name of the socket or device ifTERMstarts withxtermorrxvt. - The
PATHenviroment variable is searched for the binary to be run in the pseudo-tty.
π EMULATION π
Sympathy completely emulates a VT102 terminal (including the VT52 emulation). Periodt.
Sympathy also emulates a few extra sequences: the xterm(1) ESC ] ... sequences, and the ANSI CSI @ and CSI b sequences.
The numeric keypad follows exactly the sequences produced by an xterm rather than the exact VT102/VT220 sequences.
Sympathy also recognises the ESC % G and the ESC % @ sequences to switch between ISO-2202 and UTF-8 but ignores them (see CHARACTER ENCODING below).
π SERIAL PORT THEORY π
okay bestie, history lesson time, but make it β¨serialβ¨ π
So back in the day, a serial connexion was originally meant to hook up a DTE (Data Terminal Equipment) to a DCE (Data Circuit-terminating Equipment). The DCE (think: some kind of modem) would assert the DTE's DSR line to say "hey i'm ready π". The DTE would assert DTR to tell the DCE "okay go ahead and try to connect to the remote DCE". Once a connexion was established, the DCE would assert the DTE's CD pin. Then data could flow between the DTR and the remote DTE via the two DCEs. Flow control was handled by the RTS and CTS lines: the DTE asserts RTS when it's capable of receiving new data, and pauses its transmission of data when the CTS line is de-asserted. The local DCE asserts CTS when the remote DCE detects RTS, and vice versa. periodt.
In modern usage the signals are slightly different π¦ β for a typical connexion using modems, DSR indicates the modem is ready, a drop DTR is used to tell the modem it should break the connexion to the remote modem. CD indicates the local modem is connected to the remote modem, and CTS and RTS behave like before. Connexion is established by in-band signalling before CD gets asserted.
For a null modem cable π local DSR and DTR are wired to remote CD, local CTS to remote RTS, and local RTS to remote CTS. So asserting local DTR asserts local DSR and remote CD, and asserting local RTS asserts remote CTS.
When RTS/CTS flow control is in operation and the receive buffer becomes full, the operating system (or the hardware) de-asserts RTS, causing β via the DCEs or the null modem cable β a de-assertion of remote CTS, which in turn causes the remote DTE to cease transmission. no cap, that's the whole pipeline π
β¨ EXAMPLES β¨
π using sympathy to mimic screen(1):
[foo@barhost ~]$ sympathy
Sympathy forks π΄. The child becomes a daemon server and launches a new shell in a pseudo-tty, the original process becomes a client and connects to the server and shows the output. The user then uses the new shell and after some time either hangs up on the client or issues CTRL-B quit, and the client detaches from the server.
Later the user wishes to retrieve her session and to determine which sympathy sessions are active, so she issues:
[foo@barhost ~]$ sympathy -ls
/home/foo/.sympathy/barhost.8843 (Active)
[foo@barhost ~]$
Then she issues:
[foo@barhost ~]$ sympathy -r 8843
and boom π« she's reconnected to her session.
π using sympathy to mimic minicom(1):
[foo@barhost ~]$ sympathy -t -d /dev/modem -b 9600 -K
Sympathy opens the device /dev/modem and locks it π, sets the baud-rate to 9600 baud and disables flow control. A VT102 terminal emulator then displays the data from the modem. The user quits the emulator by issuing CTRL-B quit, which unlocks the modem and exits sympathy.
πΈ using sympathy to mimic consolidate(1):
[foo@barhost ~]$ sympathy -s -d /dev/ttyS13 -b 19200 -K -k /var/sympathy/13 -L /var/sympathy/13.log -R
Sympathy becomes a daemon and detaches from the current tty. It then opens the device /dev/ttyS13 and locks it, sets the baud-rate to 19200 baud and disables flow control. Sympathy then listens for clients connecting on the socket /var/sympathy/13, whilst logging completed lines and changes in status to the file /var/sympathy/13.log, rotating the log file when it gets too large π.
A user wishing to see the current status of /dev/ttyS13 issues:
[foo@barhost ~]$ sympathy -c -k /var/sympathy/13
or
[foo@barhost ~]$ sympathy -r 13
and the last 200 lines of history are injected into the history of her outer terminal emulator π
and she is connected to /dev/ttyS13. The user disconnects from the server by issuing CTRL-B quit.
π¦ using sympathy to mimic script(1):
[foo@barhost ~]$ sympathy -t -L typescript
Sympathy starts a shell in a ptty and logs completed lines to the file typescript. When the shell exits sympathy will terminate, or the user can press CTRL-B which will close the ptty and send a hangup to its controlling process. iconic behaviour fr fr π«Ά
π SEE ALSO π
screen(1) minicom(1) consolidate(1)
β STANDARDS β
ANSI X3.64, ISO-6429, ECMA-48, ISO-2202, ISO-8859, ISO-10646, Digital Equipment Corp. VT102.
π BUGS π
- The command editor and parser should support better line editing.
- It should be possible to change the escape character.
- The HTML generated with the
-Hoption is ugly. π - No useful error message is generated if opening the terminal device fails in the
-c-smajor mode. π
π AUTHOR π
James McKenzie, sympathy@madingley.org
okay bestie that's the whole page, you're officially a sympathy scholar now, go forth and multiplex πβ¨
This was Version 1.2.1 + Edits, dated After March 12, 2008, for sympathy(1) β slay, stay connected, and don't forget to CTRL-B quit when you're done ππ
π
π¦ where this page comes from
- debian bookworm: sympathy 1.2.1+woking+cvs+git20171124-1 Β· LGPL-2.1-or-later
- debian trixie: sympathy 1.2.1+woking+cvs+git20171124-1 Β· LGPL-2.1-or-later
- ubuntu jammy: sympathy 1.2.1+woking+cvs+git20171124-1 Β· LGPL-2.1-or-later
- ubuntu noble: sympathy 1.2.1+woking+cvs+git20171124-1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms