karana
asked on
i/o for terminals
sir ,
********** 1.c *********
int main()
{
write(0 ,"ratheesh" ,8);
}
this program will output : ratheesh on terminal
in which it is executed .
There r 3 terminals i hve opened on my p3 system
working on RedHat 8 os.
tty1 , tty2 ,tty3 .
Is there any method to change output from terminal to other without using like the below
int a =open("/dev/tty2" ,O_WRONLY);
********** 1.c *********
int main()
{
write(0 ,"ratheesh" ,8);
}
this program will output : ratheesh on terminal
in which it is executed .
There r 3 terminals i hve opened on my p3 system
working on RedHat 8 os.
tty1 , tty2 ,tty3 .
Is there any method to change output from terminal to other without using like the below
int a =open("/dev/tty2" ,O_WRONLY);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Urgl !!! Oh no :-))) NOT system().
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry forgot to show the includes.
#include <stdio.h> /* perror */
#include <unistd.h> /* write*/
#include <fcntl.h>
#include <sys/types.h>
#include <stdio.h> /* perror */
#include <unistd.h> /* write*/
#include <fcntl.h>
#include <sys/types.h>
But there is no other way than the one you're mentioning, except using shell redirection :
echo "foo" > /dev/tty2