/usr/share/doc/libdevice-gsm-perl/examples/read_messages.pl is in libdevice-gsm-perl 1.60-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | #!/usr/bin/perl
#
# Short example of use for Device::Gsm class
# Script that reads all SMS stored on SIM
#
# $Id: read_messages.pl,v 1.5 2006-04-20 20:05:45 cosimo Exp $
use strict;
use lib '../lib';
use lib '../';
use Gsm;
print "\nthis is ", '$Id: read_messages.pl,v 1.5 2006-04-20 20:05:45 cosimo Exp $', "\n";
print "\nTrying to read all messages you have on your SIM card...\n";
my $port = $ENV{'DEV_GSM_PORT'} || ( $^O =~ /Win/ ? 'COM2' : '/dev/ttyS1' );
my $myport;
my $pin = $ENV{'DEV_GSM_PIN'} || '0000';
my $mypin;
unless( $port ) {
print "Select your serial port [$port] : ";
chomp( $myport = <STDIN> );
}
$myport ||= $port;
unless( $pin ) {
print "Insert your PIN number if you need to register to GSM network [$pin] : ";
chomp( $mypin = <STDIN> );
$mypin =~ s/\D//g;
$mypin = substr( $mypin, 0, 4 );
}
$mypin ||= $pin;
my $gsm = new Device::Gsm(
port => $myport,
log => 'file,messages.log',
loglevel => 'debug'
);
die "cannot create Device::Gsm object!" unless $gsm;
my $baud = $ENV{'DEV_GSM_BAUD'} || 9600;
print "Connecting on $myport port at $baud baud ...";
$gsm->connect( baudrate => $baud ) or die "cannot connect to GSM device on [$myport]\n";
print " ok\n";
print "Registering on GSM network...";
$gsm->register() or die "cannot register on GSM network: check pin and/or network signal!";
print " ok\n";
print "Connected and registered to network.\n";
my @msg = $gsm->messages();
my $lOk = scalar @msg;
if( $lOk ) {
print "You have messages!\n" ;
my $n = 0;
foreach( @msg ) {
my $sms = $_;
next unless defined $sms;
print '-' x 60, "\n", "MESSAGE N. $n\n";
print 'Type ',($sms->type() eq Device::Gsm::Sms::SMS_SUBMIT ? 'SUBMIT' : 'DELIVER'), "\n";
print 'Status ', $sms->status(), "\n";
print 'From ', $sms->sender(), "\n";
print 'To ', $sms->recipient(), "\n";
print 'Text [', $sms->text(), "]\n";
$n++;
<STDIN>;
}
} else {
print "No message on SIM, or error during read!\n";
}
|