Common Assumptions
We have three terminals open lets say
/dev/pts/x named as
terminal-x, where
x being
0, 1 and
2.
Shell-Based Scenario
Issue the following command in terminal-2:
cp /dev/pts/1 /dev/pts/0
Now try typing some characters inside the terminal-1 and you observed that some of them (one-yes, one-not pattern) appear in the terminal-0. This means that when you type
abcdef the characters
ace are displayed in terminal-1 and the characters
bdf are displayed in terminal-0.
Programmatic Scenario
I have a text-based console program which I run from terminal-0 and use that terminal for showing status information to user.
Now I want to gather user input (text-based) from terminal-1 by performing by redirecting standard input and output to that console and then performing scanf and printf:
1 freopen("/dev/pts/1","r", stdin);
2 freopen("/dev/pts/1","w", stdout);
3 printf ("enter x");
5 scanf ("%d", &x);
Summary of Issues
1) When I enter my input string in terminal-1 and press
<enter>, it is interpreted as a command and is tried to be executed by the operating system and thus receiving a "command not found".
2) Some of the characters I type in terminal-1 are displayed and some are not!.[however the value is scanf-ed correctly in the program!]
Any kind of advice / suggestion is appreciated in advanced.