在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
通过接口发送短信的socket小样: #!/usr/bin/perl -w # auth:[email protected] # what:send message to phone # usage: sms.pl [phonenumber] [text] use strict; use Socket; if(scalar @ARGV != 2){ die "Usage: sms.pl [phonenumber] [text]\n"; } my $phone = $ARGV[0]; my $text = $ARGV[1]; my $sms_host = "xxx.xxx.xxx.xxx"; my $sms_port = 8089; socket(SOCK, AF_INET, SOCK_STREAM, getprotobyname("tcp")) or die "Error: cannot create socket\n"; connect(SOCK, sockaddr_in($sms_port, inet_aton($sms_host))) or die "Error: cannot connect sms server\n"; send(SOCK, "$phone||$text", 0) or die "Error: an unexpected exception occurred when sending message\n"; close(SOCK);
|
请发表评论