pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Perl pastebin - collaborative debugging tool View Help


Posted by pitombera on Wed 28 Jan 03:23
report abuse | download | new post

  1. #!/usr/bin/perl
  2. #
  3.  
  4. use strict;
  5. use Device::Gsm;
  6.  
  7. #
  8. die "use: $0 number ex: echo \"msg\" | (perl) $0 dd12345678\n" unless( $ARGV[0] && length( $ARGV[0] ) == 10  );
  9.  
  10. # Conf
  11. my $myport = $^O =~ /freebsd/ ? '/dev/ttyU0' : '/dev/ttyACM0'; # Define device
  12. my $mypin  = '0000'; # Define pin
  13.  
  14. my $gsm = new Device::Gsm( port => $myport, pin => $mypin, log => 'file,send.log' );
  15.  
  16. die "cannot create Device::Gsm object!" unless $gsm;
  17.  
  18. #
  19. # If you have problems with bad characters being trasmitted across serial link,
  20. # try different baud rates, as below...
  21. #
  22. # .---------------------------------.
  23. # | Model (phone/modem) |  Baudrate |
  24. # |---------------------+-----------|
  25. # | Falcom Swing (A2D)  |      9600 |
  26. # | Motorola v3/v550    |      9600 |
  27. # | Siemens C35/C45     |     19200 |
  28. # | Digicom             |      9600 |
  29. # | Nokia Communicator  |      9600 |
  30. # `---------------------------------'
  31. #
  32.  
  33. $gsm->connect( baudrate => 9600 ) or die "cannot connect to GSM device on [$myport]\n";
  34. $gsm->register() or die "cannot register on GSM network: check pin and/or network signal!";
  35.  
  36. print "\nok! connected and registered to network.\n";
  37.  
  38. # +557188116605
  39. my $prefix = '+55';
  40.  
  41. my $number = $prefix . $ARGV[0];
  42.  
  43. my $content;
  44. do {
  45. #       print "\nSMS Text (max 160 chars):\n";
  46.         chomp( $content = <STDIN> );
  47. } until $content;
  48.  
  49. $content = substr( $content, 0, 160 );
  50.  
  51. my $lOk = $gsm->send_sms(
  52.         content => $content,
  53.         recipient => $number,
  54.         class     => 'normal'     # try `flash'
  55. );
  56.  
  57. $lOk ? exit 0 : exit 1;

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post