Xref: utzoo comp.unix.questions:30153 comp.unix.wizards:24714 Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: Passing std in/out file descriptors between processes Message-ID: <1991Apr8.001600.7876@athena.mit.edu> Date: 8 Apr 91 00:16:00 GMT References: <1991Apr04.173646.983@fwhnm02.fwrdc.rtsg.mot.com> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 30 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@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710