Skip to content
Advertisement

How to attach ttyS to screen and capture it simultaneously

For capturing ssh sessions I use “script” command: “script -c ‘ssh user@host’ outfile”. But I have no idea how to capture sessions to remote hosts, that connected over com(serial) port.

screen script -c 'screen /dev/ttyS0 57600' file

ends immediately with empty log. Both 2 functions that implemented in screen is necessary: ability to switch between opened sessions and ability to perform i/o to /dev/ttyS. I started develop some tiny utility to redirect stdin/stdout to /dev/ttyS but now it’s so buggy and doesn’t work yet.

Advertisement

Answer

First off, a terminal program, like minicom (or good-ol cu), as suggested by Laszlo, is needed to communicate with the remote system. Once you can get such a program to work, then screen can be brought into the picture. Note that this also requires a getty running on the remote computer’s serial port. If it’s an old-fashioned serial port, you may also need a special null-modem cable.

Screen can be used with such a connection to be able to move access of the session across terminals. However, it cannot be used to spawn more than one session with the remote server. That’s because the program running on the serial port (getty) only supports a single session. In this case, the screen runs on the local machine, and the terminal-program session running within screen connects to the remote server. So, it is possible to have multiple screens, but just not more than one connected to the remote server over a single serial port.

With all of that said, serial ports can be used to network two machines, assuming both support the same serial-line networking protocol. Networking eliminates these restrictions.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement