You guys were so helpful, I want to share something I was hacking on today. I saw an article last week on integrating instant messaging with an application and it got me thinking. I found an MSN.pm and put together this script which will log in to MSN Messenger and listen for connections. When it receives a message, it will check to see if it is formatted correctly (that is "password::cmd") and that the password is correct. If everything jives, it processes the command and returns the results to the sender.
Notes: - This is rough and ugly, but seems to work (ymmv). (except 'password::dir c:\' will not return the results) - requires MSN.PM from http://www.adamswann.com/library/2002/msn-perl/index.html (note, on line 135 of MSN.pm, change the host name. I used the following: $Host = shift || 'baym-cs71.msgr.hotmail.com'; #'msgr-ns14.msgr.hotmail.com';) - May be win32 specific - change the userid/password on line 5 to a valid msn messenger id - change the $strpwd as well! \\Greg Martin -----included script msncl.pl (based on script at damjen.com)------ #!/usr/bin/perl use MSN; my $client = MSN->new(); $client->connect('[EMAIL PROTECTED]','msnpw', '', { Status => \&Status, Answer => \&Answer, Message => \&Message, Join => \&Join } ); sub Status { print "Status() called with parameters:\n"; print " " . join(",", @_), "\n"; } sub Message { $strpwd = "PassW0rd"; print "Message() called with parameters:\n"; my ($clnt, $usr, $nicename, $msgtxt) = @_; print $msgtxt, "\n"; @fields = split /::/,$msgtxt; $cmd = $fields[1]; if ($fields[0] eq $strpwd) { $outmsg = "Got pw, executing command"; print $outmsg . "\n"; $$clnt->sendmsg($outmsg); $output = `$cmd 2>&1`; print $output; $$clnt->sendmsg($output); } else { $outmsg = "Bad pw"; print $outmsg . "\n"; $$clnt->sendmsg($outmsg); } } sub Join { print "Join() called with parameters:\n"; print " " . join(",", @_), "\n"; } sub Answer { print "Answer() called with parameters:\n"; print " " . join(",", @_), "\n"; } -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, December 23, 2002 3:17 PM To: [EMAIL PROTECTED] Subject: Re: IF help [...] MGC> I'm certain this has an obvious answer. Why does this "if" always pass the MGC> test? MGC> $strpwd = "C0ll\@b"; ... MGC> if ($fields[0] == $strpwd) { ... as compare operator use 'eq' (for strings) instead of '==' (for numbers) _______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ************************************************************************** This e-mail and any files transmitted with it may contain privileged or confidential information. It is solely for use by the individual for whom it is intended, even if addressed incorrectly. If you received this e-mail in error, please notify the sender; do not disclose, copy, distribute, or take any action in reliance on the contents of this information; and delete it from your system. Any other use of this e-mail is prohibited. Thank you for your compliance. _______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
