I have a perl script for unix which uses a socket to read data from gsm modem connected to com port.I need to convert it to windows.I think most of the script is going to be same except the line which establishes the socket connection.
Could someone please help me to know which lines I should change so that it will work on windows.
Here is the script
#!/usr/bin/perl -w
# TRG: Perl script to exercise GSM card through a set of diagnostic commands
# The results from each command are sent back to the browser client
# Accesses the GSM card via gsmd socket (for sharing)
use strict;
use IO::Socket::UNIX;
use Term::ReadKey;
use IO::Select;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
# Keep Apache happy with the content
print "Content-type: text/htmlnn";
# Open the socket connection to GSMD
my $sock = new IO::Socket::UNIX (Type => SOCK_STREAM,
Peer => '/home/glucose/gsm/gsmd_sock',
Timeout => 60) || die "Couldn't establish socket: $!";
$! = 1;
my $s = IO::Select->new();
$s->add($sock);
$sock->autoflush(1);
ReadMode 4;
# Display suitable HTML headers and send a series of commands
#print "GSM Card Diagnosticsn";
sendcommand($s,$sock,"at+cerrn",'Last Error Message','');
sendcommand($s,$sock,"at+cscs="GSM"n",'Select ASCII output','');
print "GSM Card Detailsn";
sendcommand($s,$sock,"at+cgmin",'Manufacturer Indentification','');
sendcommand($s,$sock,"at+cgmmn",'Model Identification','');
sendcommand($s,$sock,"at+cgmrn",'Revision','');
sendcommand($s,$sock,"at+cgsnn",'Serial Number','');
print "Subscriber Identificationn";
sendcommand($s,$sock,"at+cimin",'International Mobile Subscriber Identity','');
sendcommand($s,$sock,"at+ccidn",'SIM card ID','');
sendcommand($s,$sock,"at+gcapn",'List of capabilities','');
sendcommand($s,$sock,"at+cnumn",'Subscriber number','');
printf "Current Statusn";
sendcommand($s,$sock,"at+cpasn",'Status','(0=ready , 1=unavailable, 2=unknowm, 3=ringing, 4=call-in-progress, 5=asleep');
sendcommand($s,$sock,"at+cfun?n",'Functions','(pow er,stk)');
sendcommand($s,$sock,"at+cmer?n",'Term event reporting','(mode,kpd,disp,ind,bfr)');
sendcommand($s,$sock,"at+cclk?n",'clock','(yy/mm/dd hh:mm:ss)');
sendcommand($s,$sock,"at+csqn", 'Signal Strength','(rssi,ber)');
sendcommand($s,$sock,"at+creg?n",'Network registration ','(n,stat,location,cellident) stat=1(home) ');
printf "SMSn";
sendcommand($s,$sock,"at+cnmi?n",'New Message Indication');
sendcommand($s,$sock,"at+csca?n",'Service centre address');
sendcommand($s,$sock,"at+cmgln",'List messages');
sendcommand($s,$sock,"at+cscs="HEX"n",'Hex output','');
# Close the socket connection and were done
$sock->close();
ReadMode 0;
exit;
# -----------------------------------------------------------------
# Subroutine to send a command to the diagnostic socket and print the response
sub sendcommand {
my $s = shift;
my $sock = shift;
my $cmd = shift;
my $desc = shift;
my $comment = shift;
my $rtn = '';
#print description
print "$desc ";
#send the command
$sock->syswrite($cmd);
sleep 1;
# read the response and print
while ($s->can_read(0))
{
$sock->sysread($rtn,1);
print $rtn;
}
print "n $commentn";
return;
}