#!/usr/bin/perl # Parseform Sub-Routine. # Usage: drop sub into CGI script. When you need to parse the form, # do a &parseform; . The data is stored in the %FORM hash. To access, # use the form $FORM{'field_name'} . # From http://www.cgi.tj/ sub parseform { if ($ENV{'REQUEST_METHOD'} eq 'GET') {@pairs = split(/&/, $ENV{'QUERY_STRING'});} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); } else { print "Content-Type: text/html\n\n"; print "

Bad or unknown request method.

\n"; exit(0); } foreach $pair (@pairs) { local($name, $value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///g; $FORM{$name} = $value; } } &parseform; print "Content-Type: text/html\n\n"; print ""; if ($FORM{'op_mode'} eq "ShutDown") { print "
";
  print "Shutting down all applications...\n";
  system("echo \"Shutting down all applications...\" | /home/bee/speakit.pl >/dev/null 2>&1 &") == 0
         or print "speakit.pl execution failed: $?";

  system("killall tcxServer") == 0
         or print "Shutdown of tcxServer failed: $?";
  system("killall laserServer");
  sleep 2;  
  
  print "
"; } if ($FORM{'op_mode'} eq "Demo") { print "
";
   print "Starting demo mode...\n";
#   use Time::Local;
#   ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
#   print "timelocal finished...\n";

   # Startup tcxServer, then wait 1 second
   system("cd /home/bee; bin/tcxServer >'/home/httpd/html/logs/tcxServer.log' 2>&1 &") == 0
         or print "tcxServer startup failed: $?";
   sleep 1;
   system("cd /home/bee; bin/baseServer >/home/httpd/html/logs/baseServer.log 2>&1 &") == 0
         or print "baseServer startup failed: $?";
   sleep 1;
   system("cd /home/bee; bin/buttonServer >/home/httpd/html/logs/buttonServer.log 2>&1 &") == 0
         or print "buttonServer startup failed: $?";
   system("cd /home/bee; bin/pantiltServer >/home/httpd/html/logs/pantiltServer.log 2>&1 &") == 0
         or print "pantiltServer startup failed: $?";

   # This is really kudgy
   system("export TCXHOST=zaza1; cd /home/bee; bin/laserServer >/dev/null 2>&1 &") == 0
         or print "laserServer startup failed: $?";
   sleep 8;
   system("killall laserServer");
   system("export TCXHOST=zaza1; cd /home/bee; bin/laserServer >/dev/null 2>&1 &") == 0
         or print "laserServer startup failed: $?";
   sleep 8;
   system("killall laserServer");
   system("export TCXHOST=zaza1; cd /home/bee; bin/laserServer >/home/httpd/html/logs/laserServer.log 2>&1 &") == 0
         or print "laserServer startup failed: $?";

    system("cd /home/bee-new; src/beeExamples/buttoncall >/home/httpd/html/logs/buttoncall.log 2>&1 &") == 0
         or print "buttoncall startup failed: $?";
    sleep 2;

#    system("cd /home/brudy/bee; src/beeExamples/wander-laser -usePantilt=N -useLaser=N -exploreRange=800 >/dev/null 2>&1 &") == 0
#         or print "wander-laser startup failed: $?";

    system("echo \"Ready for demo!\" | /home/bee/speakit.pl >/dev/null 2>&1 &") == 0
         or print "speakit.pl execution failed: $?";

   print "
\n"; } print<

Mode

eof # print "
The value of op_mode is:" . $FORM{'op_mode'} . "\n<\pre>\n"; 


print "\n";