If you are a user, (not root) , you need permissions to /dev/ttyS0
As a test, you could chmod 777 /dev//ttyS0 and see what happens.
It's pretty common to make the serial ports, owned by group UUCP,
(a relic from the old days), so you may need to add yourself to
group UUCP.
If you have serial mouse, and its on /dev/ttyS0 (com1) you may lock up
your X server, so be careful.
Your best bet is to use the module Device::SerialPort, because a serial
device dosn't act like a normal filehandle
Here is a simple example of trying to do it manually.
Device::SerialPort handles all these complications.
############################################
#!/usr/bin/perl
use strict;
use warnings;
#by John Sterling from a usenet post
sub readUntil {
my $port = shift;
my $pat = shift;
my $data = "";
my $buf = "";
my $br;
my $timeout = 10000;
do {
$br = sysread($port, $buf, 256);
$data .= $buf if $br > 0;
} while ($data !~ /$pat/i && $timeout--);
return $data;
}
my $port;
open ($port, "+</dev/ttyS0") || die "cannot open port S0: $!n";
# you will have to tweak this depending on your comm protocol
# my guess is that raw might do what you want
system("stty 9600 raw < /dev/ttyS0");
syswrite($port, "r");
readUntil($port,"login:");
syswrite($port, "$userr");
readUntil($port,"assword");
syswrite($port,"$passwordr");
readUntil($port,"Terminal Type?");
syswrite($port,"vt100r");
readUntil($port,"#");
syswrite($port, "ioscanr");
# I am just dumping the output of the ioscan command to a file
# you probably want to do something else
my $output = readUntil($port,"#");
my $outfile;
open ($outfile,">data.txt");
print $outfile $output;
close $outfile;
syswrite($port, "exitr");
close $port;
__END__
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html