<p>What is the best way to setup one Linux box to listen on its serial port for incoming connections? I've done a lot of googling but I can't find the right combination of commands to actually get them to talk!</p>

<p>My main objective is to provide a serial interface to running instances of kvm/qemu VMs. They currently only have a VNC interface (they are on headless servers, no X). I can get the VM to create a serial device by starting it with the -serial file: flag, but how to talk to it, is a whole other problem. Both boxes are running Ubuntu 8.04.</p>

[{'answer_id': 69706, 'author': 'Hein', 'author_id': 9399, 'author_profile': 'https://Stackoverflow.com/users/9399', 'pm_score': 0, 'selected': False, 'text': '<p>I assume you connect the two serial ports using a "null modem" cable.</p>\n\n<p>Use a program like minicom to talk to remote system -- you probably need to set up the communication parameters and possibly turn off hardware flow control (if your cable doesn\'t have the flow-control lines connected).</p>\n'}, {'answer_id': 74147, 'author': 'Commodore Jaeger', 'author_id': 4659, 'author_profile': 'https://Stackoverflow.com/users/4659', 'pm_score': 4, 'selected': True, 'text': '<p>The <a href="http://tldp.org/HOWTO/Serial-HOWTO.html" rel="noreferrer">Linux Serial HOWTO</a> has a lot of detailed information about serial communication in general. The more-specific <a href="http://tldp.org/HOWTO/Remote-Serial-Console-HOWTO/index.html" rel="noreferrer">Linux Remote Serial Console HOWTO</a> is what you\'re really looking for if you want to be able to log into your virtualized systems using the serial port as if you were at the console. As Hein indicated, you\'ll need a null modem cable and need to run minicom on the remote terminal.</p>\n\n<p>The Linux console is used in two ways, each of which must be configured separately for serial use. You can configure the kernel to copy its messages over the serial port, which is occasionally interesting for watching the system boot and nearly indispensable if you\'re doing kernel debugging. (This requires kernel support and updating the boot parameters so the kernel knows you want serial output; see <a href="http://tldp.org/HOWTO/Remote-Serial-Console-HOWTO/configure-kernel.html" rel="noreferrer">chapter 5</a> of the second howto.) You\'re probably more interested in logging in via the serial port, which requires running getty on the serial port after boot (just like your system already runs getty on the virtual terminals after boot), which is described in detail in <a href="http://tldp.org/HOWTO/Remote-Serial-Console-HOWTO/getty.html" rel="noreferrer">chapter 6</a> of the howto.</p>\n'}, {'answer_id': 74208, 'author': 'catfood', 'author_id': 12802, 'author_profile': 'https://Stackoverflow.com/users/12802', 'pm_score': 0, 'selected': False, 'text': '<p>Say you\'re doing this on /dev/tty1.</p>\n\n<p><strong>in the shell</strong></p>\n\n<pre><code>chown *youruser* /dev/tty1\n</code></pre>\n\n<p><strong>then in a Perl script called example.pl</strong></p>\n\n<pre><code>open PORT, "&lt;/dev/tty1" || die "Can\'t open port: $!";\nwhile (defined ($_ = &lt;PORT&gt;))\n{\n do_something($_);\n}\nclose PORT;\n</code></pre>\n\n<p>Obviously there is more to do if you want this to start automatically, and respawn on error, and so on. But the basic idea is to read from the serial port like a file.</p>\n'}]
['https://Stackoverflow.com/questions/69692', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11105/']