add kvpairs2td
[hband-tools.git] / user-tools / ttinput
blobfd8f292d59538143c3f8538f8f337289d4c6700e
1 #!/usr/bin/env perl
3 true <<EOF
4 =pod
6 =head1 NAME
8 ttinput - Inject console input in a terminal as if the user typed
10 =head1 SYNOPSIS
12 echo Lorm ipsum | ttinput /dev/pts/1
14 =head1 CREDITS
16 L<https://johnlane.ie/injecting-terminal-input.html>
18 =cut
20 EOF
24 $tty = shift @ARGV || '/dev/tty';
25 sysopen $fd, $tty, O_WRONLY|O_NONBLOCK or die "open $tty: $!\n";;
27 while(<STDIN>)
29 for $ch (split //)
31 ioctl($fd, 0x5412, $ch) or die "ioctl: $!\n";