Passing std in/out file descriptors between processes

Jonathan I. Kamens jik at athena.mit.edu
Mon Apr 8 10:16:00 AEST 1991


It seems to me that something like this would work:

  1) Write a program to run on the US machine, either constantly listening on
a particular TCP port or run by inetd when a connection is received on that
port.  Once this program starts up, it sends all input from the network
connection to the serial port of the box, and all output from the serial port
of the box to the network connection.  You might want to do some sort of
authentication (e.g. a password as the first thing sent over the port from the
remote connection) to prevent just anyone from connecting to the box over the
network.

  2) On the International host, write a short program which connects to the
port on the US host, sends the password if necessary, dup2()s the
socket file descriptor over file descriptors 0, 1, and 2, and then exec()s the
program that has to be able to talk to the remote device.  Presto, that
program thinks it's talking directly to the remote device; it doesn't have to
know that it's over a network socket instead of over a serial line.

  You could probably accomplish the same thing without writing any source code
of your own (i.e. only writing scripts) using the  expect package (see the
comp.unix.questions FAQ for information about getting the sources to it).  You
might also be able to do it with the pty package (again, see the FAQ), but
your system might need to be able to support named pipes in order to do it
that way.

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list