johnnyr@ihu1m.UUCP (John R. Rosenberg) (05/14/85)
I am a (very) novice C programmer. I would like to write a simple screen manager using curses to keep a copy of about 5 screens that can be scrolled up and down in order to, in effect, add screen memory to a terminal. I need to know if there is a way to pass strings input to this program to the shell for execution (such as pwd or cd etc.) and have the resulting output from the shell directed back to the program so that it can be addeed to the screen memory. Any help would be appreciated. John Rosenberg ihnp4!ihu1m!johnnyr
gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (05/17/85)
> ... I need to know if there is a way > to pass strings input to this program to the shell > for execution (such as pwd or cd etc.) and have > the resulting output from the shell directed back > to the program ... Sure, but you have to be careful. Trying to attach pipes for both input & output from the subshell is too hard, since the possibility of deadlock exists. Put input for the subshell into a file, then invoke the popen() library function to run "shellname <filename" in "r" mode, followed by invocations of getc() to read the output returned from the shell.
alexis@reed.UUCP (Alexis Dimitriadis) (05/21/85)
> > ... I need to know if there is a way > > to pass strings input to this program to the shell > > for execution (such as pwd or cd etc.) and have > > the resulting output from the shell directed back > > to the program ... > > Sure, but you have to be careful. Trying to attach pipes > for both input & output from the subshell is too hard, > since the possibility of deadlock exists. [...] Also, this will break may programs that modify their behavior when their input or output is/is not a terminal. (e.g. csh, ls, more, etc.). If your system has ptys, (pseudo-ttys) you should use them. They appear as /dev/pty* if you have them. -- _______________________________________________ As soon as I get a full time job, the opinions expressed above will attach themselves to my employer, who will never be rid of them again. alexis @ reed ...teneron! \ ...seismo!ihnp4! - tektronix! - reed.UUCP ...decvax! /