pitombera
By: a guest | Jan 27th, 2009 | Syntax:
Perl | Size: 1.55 KB | Hits: 156 | Expires: Never
#!/usr/bin/perl
#
use strict;
use Device::Gsm;
#
die "use: $0 number ex: echo \"msg\" | (perl) $0 dd12345678\n" unless( $ARGV[0
] && length( $ARGV[0
] ) == 10
);
# Conf
my $myport = $^O =~ /freebsd/ ? '/dev/ttyU0' : '/dev/ttyACM0'; # Define device
my $mypin = '0000'; # Define pin
my $gsm = new Device
::Gsm( port
=> $myport, pin
=> $mypin, log => 'file,send.log' );
die "cannot create Device::Gsm object!" unless $gsm;
#
# If you have problems with bad characters being trasmitted across serial link,
# try different baud rates, as below...
#
# .---------------------------------.
# | Model (phone/modem) | Baudrate |
# |---------------------+-----------|
# | Falcom Swing (A2D) | 9600 |
# | Motorola v3/v550 | 9600 |
# | Siemens C35/C45 | 19200 |
# | Digicom | 9600 |
# | Nokia Communicator | 9600 |
# `---------------------------------'
#
$gsm->connect( baudrate
=> 9600
) or die "cannot connect to GSM device on [$myport]\n";
$gsm->register() or die "cannot register on GSM network: check pin and/or network signal!";
print "\nok! connected and registered to network.\n";
# +557188116605
my $prefix = '+55';
my $number = $prefix . $ARGV[0];
my $content;
do {
# print "\nSMS Text (max 160 chars):\n";
chomp( $content = <STDIN> );
} until $content;
$content = substr( $content, 0
, 160
);
my $lOk = $gsm->send_sms(
content => $content,
recipient => $number,
class => 'normal' # try `flash'
);