Deleuze has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use Net::AIMTOC; use Term::ReadKey; $version = 0.01; #The version number $screenname = ""; #Contains the screenname for logging in $password = ""; #Password for logging in $out = "STDOUT"; #Set default output to the screen @targets; #Array containing screennames to watch # process($) # Takes next argument as parameter. # Checks to see if it's a flag, otherwise # considers it a screenname and adds to list. sub process_args($) { my $iterate = 0; #Local variable for adding to @targets if ($_[0] eq "-v" || $_[0] eq "--version") { print "Thanks for supporting AimSpy. You are currently using +version $version of AimSpy.\n"; } elsif ($_[0] eq "-h" || $_[0] eq "--help") { } #help info elsif ($_[0] eq "-o") { #check for output file spec. $save = shift @ARGV; open($out = SAVE, ">>$save") or open($out = SAVE, ">$save") or die "Can't save to file $save: $!\n"; } elsif ($_[0] eq "-i") { #check for input file spec. $read = shift @ARGV; open(INPUT, "$read") or die "Could not open file: $!\n"; $iterate = 0; while(<INPUT>) { $targets[$iterate] = $_; $iterate++; } } else { #everything else is a screenname $targets[$iterate] = $_[0]; $iterate++; } } # login() # Logs in to AIM. Prompts sn and pw. # Establishes connection to AOL. # Doesn't really do too much else.... sub login() { if (!@ARGV) { #We need someone to spy on. die "No targets specified!"; } if ($screenname eq "") { print "Enter your screenname: "; chomp($screenname = <STDIN>); print "\nEnter your password: "; ReadMode 2; chomp($password = <STDIN>); ReadMode 0; } try { $aim = Net::AIMTOC->new; $aim->connect; $aim->sign_on($screenname, $password); } catch Net::AIMTOC::Error with { my $err = shift; print $err->stringify, "\n"; }; foreach my $iterate (@targets) { $aim->add_online_buddies("aimspy", $iterate); } } sub monitor() { while (1) { my $msg = $aim->recv_from_aol(); if ($msg->getType eq 'UPDATE_BUDDY' && $msg->getBuddy eq @targ +ets) { print $out $msg->getBuddy, " turned ", $msg-getOnlineStatu +s, " at this time.\n"; } elsif ($msg->getType eq 'IM_IN') { print $out "Message ", $msg->getMsg, " received from ", $m +sg->getSender, " at this time.\n"; } elsif ($msg->getType eq 'ERROR') { print $out "Error ", $msg->getMsg, " received at this time +.\n"; } } } while (@ARGV) { #process arguments process_args(shift @ARGV); } login; monitor;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Script help
by demerphq (Chancellor) on Jun 22, 2003 at 17:47 UTC | |
by Aristotle (Chancellor) on Jun 22, 2003 at 19:34 UTC | |
by demerphq (Chancellor) on Jun 22, 2003 at 19:40 UTC | |
|
Re: Script help
by castaway (Parson) on Jun 22, 2003 at 17:14 UTC | |
|
Re: Script help
by dash2 (Hermit) on Jun 22, 2003 at 17:49 UTC | |
|
Re: Script help
by antirice (Priest) on Jun 23, 2003 at 00:19 UTC |