#!/usr/bin/perl -w
use POSIX;
eval 'sub O_NDELAY () { &O_NONBLOCK;}' unless defined(&O_NDELAY);
eval 'sub TCFLSH () {0x540b;}' unless defined(&TCFLSH);
eval 'sub TIOCSTI () {0x5412;}' unless defined(&TIOCSTI);
if(@ARGV < 2) {
print "usage : force <device> <command string>\n";
exit;
}
$Device = shift(@ARGV);
$Command = join(' ',@ARGV);
sysopen($DEVICE,$Device,&O_NDELAY|O_RDWR)||die "cannot open device '$D
+evice' : $!\n";
if(ioctl($DEVICE,&TCFLSH,0) < 0) {
print "ioctl TCFLSH error on '$Device' : $!\n";
}
foreach $Char (split(//,"$Command\n")) {
if(!(ioctl($DEVICE,&TIOCSTI,$Char))) {
print "ioctl TIOCSTI error on '$Device': $!\n";
}
}
close($DEVICE)||die "cannot close device '$Device' : $!\n";
In reply to force.pl
by ixo111