Simulate input/Keyboard: Difference between revisions

Content added Content deleted
Line 331: Line 331:
Perl on linux can do this for PseudoTerminals (ptys) and Terminals (ttys) using [http://www.kernel.org/doc/man-pages/online/pages/man4/tty_ioctl.4.html IOCTL TIOCSTI]. The same can be done with C or any other language that can use IOCTL either natively or via [http://en.wikipedia.org/wiki/Foreign_function_interface FFI] such as [http://en.wikipedia.org/wiki/Java_Native_Interface JNI] or [http://en.wikipedia.org/wiki/Java_Native_Access JNA].
Perl on linux can do this for PseudoTerminals (ptys) and Terminals (ttys) using [http://www.kernel.org/doc/man-pages/online/pages/man4/tty_ioctl.4.html IOCTL TIOCSTI]. The same can be done with C or any other language that can use IOCTL either natively or via [http://en.wikipedia.org/wiki/Foreign_function_interface FFI] such as [http://en.wikipedia.org/wiki/Java_Native_Interface JNI] or [http://en.wikipedia.org/wiki/Java_Native_Access JNA].



How to get the correct value for TIOCSTI is discussed [http://www.perlmonks.org/?node_id=10920 (here)].


Target may be externally created, but process must be able to open tty/pty for writing.
Target may be externally created, but process must be able to open tty/pty for writing.


<lang perl>$target = "/dev/pts/51";
<lang perl>$target = "/dev/pts/51";
### How to get the correct value for $TIOCSTI is discussed here : http://www.perlmonks.org/?node_id=10920
$TIOCSTI = 0x5412 ;
$TIOCSTI = 0x5412 ;
open(TTY,">$target") or die "cannot open $target" ;
open(TTY,">$target") or die "cannot open $target" ;