#!/usr/bin/perl -w use LWP::Simple; #camhax.pl - sub_zenith 15 February 2006 $host = pop; $opt = pop; if (!defined $host) { haxhelp(); } if ($opt =~ /-h/) { haxhelp(); } if ($opt =~ /-s/) { $sequence = 1; } sub haxhelp { print < -h: Show this help -s: Move the camera in a set sequence (the default is random movement) EOF exit; } if ($sequence == 1) { print "Enter the movement sequence in L R U D, ie: LRRRUDLLDDDRRRRUUUU\n"; chomp($seq = ); @aseq = split(//, $seq); print "Entering Sequence Mode\n"; sequence(); } else { print "Entering Random Mode\n"; random(); } sub sequence { while (1) { foreach $mov (@aseq) { if ($mov =~ /L/i ) { camsend(PanLeft, Left); } elsif ($mov =~ /R/i ) { camsend(PanRight, Right); } elsif ($mov =~ /U/i ) { camsend(TiltUp, Up); } elsif ($mov =~ /D/i ) { camsend(TiltDown, Down); } else { print "$mov is not a valid command\n"; sleep 1 } } } } sub random { while (1) { $num = int(rand(4)); if ($num == 0 ) { camsend(PanLeft, Left); } elsif ($num == 1 ) { camsend(PanRight, Right); } elsif ($num == 2 ) { camsend(TiltUp, Up); } elsif ($num == 3 ) { camsend(TiltDown, Down); } else { print "WTF?!\n"; } } } sub camsend { $result = get "http://$host/nphControlCamera?Direction=$_[0]" or die "Unable to access camera\n"; if (defined $result) { print "Moved $_[1]\n"; } }