131
### This program is free software; you can redistribute it and/or modify
132
### it under the terms of the GNU General Public License as published by
133
### the Free Software Foundation; version 2 of the License
135
### This program is distributed in the hope that it will be useful,
136
### but WITHOUT ANY WARRANTY; without even the implied warranty of
137
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
138
### GNU General Public License for more details.
140
### You should have received a copy of the GNU General Public License
141
### along with this program; if not, write to the Free Software
142
### Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
146
### amsn remote control
148
### just another way to control amsn
149
### you can use this program in your scripts in an easier way
150
### than using amsn-remote-CLI
152
### written by David Mu�oz ( voise at tiscali.es )
156
### ./amsnctl.pl [stuff]
160
### --cmd [cmd] : amsn remote command (mandatory)
161
### --login [user] : session login (mandatory)
162
### --passwd [pass] : amsn server password (mandatory)
163
### --host [IP] : ip, default 127.0.0.1
164
### --port [port] : port, default 63251
167
### Example (notice the use of " and \" in command)
169
### ./amsnctl.pl --login me@hotmail.com --passwd mypasswd --cmd "setnick \"me - programming in perl\""
175
### you MUST install Perl-HMAC package
178
use Digest::HMAC_MD5;
182
### do you think i like commenting code?
184
GetOptions("host=s" => \$host,
187
"passwd=s" => \$pass,
190
if (!defined($host)) {
194
if (!defined($port)) {
198
if (!defined($acc)) {
199
die "You must scpecify a login name\n";
202
if (!defined($pass)) {
203
die "You must specify a password\n";
206
if (!defined($cmd)) {
207
die "You must specify a command\n";
210
my $sock = new IO::Socket::INET (
216
die "Amsn server closed?\n" unless $sock;
219
print $sock "$acc\n";
227
my $sock2 = new IO::Socket::INET (
232
die "Amsn server closed?\n" unless $sock;
234
$sock2->autoflush(1);
235
print $sock2 "auth\n";
240
$hmac = Digest::HMAC_MD5->new($reto);
242
$digest = $hmac->hexdigest;
244
print $sock2 "auth2 $digest\n";
247
print $sock2 $cmd."\n";
248
print $sock2 "quit\n";
257
### This program is free software; you can redistribute it and/or modify
258
### it under the terms of the GNU General Public License as published by
259
### the Free Software Foundation; version 2 of the License
261
### This program is distributed in the hope that it will be useful,
262
### but WITHOUT ANY WARRANTY; without even the implied warranty of
263
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
264
### GNU General Public License for more details.
266
### You should have received a copy of the GNU General Public License
267
### along with this program; if not, write to the Free Software
268
### Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
272
### amsn remote control
274
### just another way to control amsn
275
### you can use this program in your scripts in an easier way
276
### than using amsn-remote-CLI
278
### written by David Mu�oz ( voise at tiscali.es )
282
### ./amsnctl.pl [stuff]
286
### --cmd [cmd] : amsn remote command (mandatory)
287
### --login [user] : session login (mandatory)
288
### --passwd [pass] : amsn server password (mandatory)
289
### --host [IP] : ip, default 127.0.0.1
290
### --port [port] : port, default 63251
293
### Example (notice the use of " and \" in command)
295
### ./amsnctl.pl --login me@hotmail.com --passwd mypasswd --cmd "setnick \"me - programming in perl\""
301
### you MUST install Perl-HMAC package
304
use Digest::HMAC_MD5;
308
### do you think i like commenting code?
310
GetOptions("host=s" => \$host,
313
"passwd=s" => \$pass,
316
if (!defined($host)) {
320
if (!defined($port)) {
324
if (!defined($acc)) {
325
die "You must scpecify a login name\n";
328
if (!defined($pass)) {
329
die "You must specify a password\n";
332
if (!defined($cmd)) {
333
die "You must specify a command\n";
336
my $sock = new IO::Socket::INET (
342
die "Amsn server closed?\n" unless $sock;
345
print $sock "$acc\n";
353
my $sock2 = new IO::Socket::INET (
358
die "Amsn server closed?\n" unless $sock;
360
$sock2->autoflush(1);
361
print $sock2 "auth\n";
366
$hmac = Digest::HMAC_MD5->new($reto);
368
$digest = $hmac->hexdigest;
370
print $sock2 "auth2 $digest\n";
373
print $sock2 $cmd."\n";
374
print $sock2 "quit\n";