dga@cs.brown.edu (Daniel Gerardo Aliaga) (05/07/91)
Is there any way for a process to write a string to its stdin, such that it
can later be read again ?
For example, the following code does the job on SunOS:
#include <stdio.h>
#include <sys/termios.h>
main()
{
static char msge[256] = "hello world";
char buf[256];
int i;
printf("prompt> ");
fflush(stdout);
for (i=0; i<strlen(msge); i++)
ioctl(0, TIOCSTI, &msge[i]);
gets(buf);
printf("input was: %s\n",buf);
}
But we would like to do the same on HPUX or generically on System V.
Thanks in advance.
XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX Daniel G. Aliaga '91
XXX XXX XXXXX Brown University
XXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXX "Real men write self modifying code"
tchrist@convex.COM (Tom Christiansen) (05/07/91)
From the keyboard of dga@cs.brown.edu (Daniel Gerardo Aliaga): :Is there any way for a process to write a string to its stdin, such that it :can later be read again ? : :For example, the following code does the job on SunOS: [BSD TIOCSTI example deleted]. You're not stuffing to stdin -- you're doing it to the tty. Not the same thing, you know. I don't think you can do what you want to do generically. --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "So much mail, so little time."