Serial comms - script to poll /dev/ttyS0
I am setting up a test involving 2 machines. brezhnev - a headless Slackware 9 server, and alexis, a battered old laptop with Slack 8.1. I aim to simulate a situation where alexis will be used to monitor the serial port on a P(A)BX. In this test I will present dummy data to ttyS0 on brezhnev, and read it over a null modem cable into a file on alexis.
I have so far managed to set up brezhnev to look for a login on his first serial port when he boots, by including the following line in his /etc/inittab:
s1:12345:respawn:/sbin/agetty -L ttyS0 9600 vt100
I fire up minicom on alexis, configure it, reboot brezhnev and when he comes back up, I get a login. I am then able to dump data out onto brezhnev's serial port with the following command:
root@brezhnev:$ cat logfile > /dev/ttyS0
The contents are dumped into the login screen within minicom on alexis. This indicates that the serial comms are working between the two, but I would like to script the interaction to make it run automatically and inifnitely.
My latest attempt involved installing the UUCP slackware package and using the 'cu' utility. The command below initiates a connection:
cu -l /dev/ttyS0 --parity=none -s9600
And then I have to issue the command '~c' to download a file from brezhnev. From that point, all data echo'd to brezhnev's ttyS0 is visible to alexis, however, this still isn't automated, because I have to issue the '~c' command. I have tried hacking together a PERL script - it works as far as making the connection, but I can't maintain the dialogue (don't know what else to call it) to send this final command to the process.
Does anyone have any idea of how I could script this UUCP solution, or of another way to develop a script to check the serial port on an infinite loop for data - and then do something with it... ?