dddean@bluemoon.uucp (David D. Dean) (01/27/91)
Hello :-) I was wondering if there was a special command that I had to use to have a program of mine - when I run it - accept input from another terminal? I have tried many times with different forms of: read ANW < /dev/dk??? while (true) do cat (filename) done& (then have the other terminal write to (filename) I think that what I'll have to do, is to setup a sub-routine to always check a set file for new input and then grep the info in that file. If anyone can understand this mad reasoning.... any input would be appreciated! Thanks! David D. Dean, President Explorer Post 891 AT&T Bell Laboratories dddean@bluemoon.uucp
les@chinet.chi.il.us (Leslie Mikesell) (01/29/91)
In article <NZVFw1w163w@bluemoon.uucp> dddean@bluemoon.uucp (David D. Dean) writes: > I was wondering if there was a special command that I had to use >to have a program of mine - when I run it - accept input from another >terminal? I have tried many times with different forms of: > read ANW < /dev/dk??? > > while (true) do > cat (filename) > done& > (then have the other terminal write to (filename) > > >I think that what I'll have to do, is to setup a sub-routine to always >check a set file for new input and then grep the info in that file. As with most programming problems there are many solutions and the most appropriate one depends on what you are trying to do. The most likely problems with trying to directly read from another terminal are: A) You don't have read permission on the device. (Solution: chmod appropriatly). B) Another program (i.e. the user's shell) is reading at the same time. (Solution: prevent that program from reading for the duration of the access - for example, tell the shell to sleep awhile). C) If no other program is using the device, the stty modes need to be set appropriately for the terminal. (Solution: use stty redirected to the other device within a loop that prevents the devices from being closed until you are done with it.) One quick and easy solution is to use a FIFO to pass the information. (If your system supports FIFOs). Just "/etc/mknod FIFO p". Then you can write to it from one program and read from another with it acting pretty much like a pipe. Then you would run a program at the other terminal that interacts with the user and writes to the FIFO. Les Mikesell les@chinet.chi.il.us
decanio@shadow (Tom DeCanio) (01/29/91)
You write: > I was wondering if there was a special command that I had to use >to have a program of mine - when I run it - accept input from another >terminal? I have tried many times with different forms of: > read ANW < /dev/dk??? > > while (true) do > cat (filename) > done& > (then have the other terminal write to (filename) > > >I think that what I'll have to do, is to setup a sub-routine to always >check a set file for new input and then grep the info in that file. That may depend upon what type of device "/dev/dk???" you are attempting to read from. The only device I am familiar with that go by that name are Datakit/ISN devices. If so these devices are usually not hard wired and aren't automatically available to be read/written upon open. You must do through a call setup sequence first. Tom