I once wrote a Perl script for my friend Tian Yi, which is mainly used for alarm of Nagios server faults. It is very simple and mainly uses the lwp: simple module to request the SMS Service API.
#! /Usr/bin/perl-W <br/> use strict; </P> <p> Use lwp: simple; <br/> Use URI: escape; <br/> Use Digest: MD5; </P> <p> my ($ mobile, $ content) = @ argv; # Get Params from command line <br/> my $ log_control = 1; # a switch of log <br/> my $ username = 'sery '; # Your SMS service username <br/> my $ Password = 'abcdefg'; # Your SMS service password <br/> my $ key = 'ysdbyhd6t '; # Your SMS service key <br/> my $ souce_conten T = substr ($ mobile, 0, 8 ). substr ($ mobile,-10, 10 ). $ key; </P> <p> my $ MD5 = Digest: MD5-> New; <br/> $ MD5-> Add ($ souce_content ); <br/> my $ keyword = UC ($ MD5-> hexdigest); </P> <p> my $ result = get "http://http.asp.sh.cn/MT.do? Username = $ username & <br/> Password = $ password & mobile = $ mobile & content = $ content & keyword = $ keyword "; </P> <p> if ($ log_control) {<br/> my $ FH; <br/> open ($ FH, '>/var/log/SMS. log ') or die "can't open log: $! "; # Make sure have permission <br/> Print $ FH join ('', time, $ result, "/N"); <br/> close $ FH; <br/>}