Weblog entry #58 for Utumno
Hello Debian gurus,
I've got a Linux-based gizmo. There is a process running there; it is connected to (serial) terminal /dev/ttyS0.
I can connect to the terminal ( as root ) ,issue commends and control the process. Now I would like to make the process be remotely-controlled, i.e. I would like to write a program that
1) listens on some ip port
2) passes on all commands it gets to the process I want to control
I know how to do 1), but I have no idea how to do 2). Any ideas?
I cannot modify the process in question, all I can do is somehow try to inject a command to its controlling terminal. But simple attempts like 'echo abcd > /dev/ttyS0' do not seem to work - the 'abcd' gets sent to the process I want to control, but does not get executed by it, because the ending 'ENTER' does not seem to get passed.
Comments on this Entry
[ Send Message | View Utumno's Scratchpad | View Weblogs ]
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
int main(void)
{
int hTTY = open("/dev/tty1", O_WRONLY|O_NONBLOCK);
ioctl(hTTY, TIOCSTI, "p");
ioctl(hTTY, TIOCSTI, "\n");
close(hTTY);
return 0;
}
[ Parent | Reply to this comment ]