Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
leaving no error message. I ran it from the command line and it runs into trouble when universedAction=Start is sent in the query string. I used the debugger to step into the if statement but I still can't see what the problem is...
#!/usr/local/bin/perl use strict; no strict "refs"; use CGI; use Proc::ProcessTable; our $statusCGI = new CGI; # Configuration variables our $acmePath = "/usr/local/acme"; our $universedBin = "universed"; our $worldBin = "world"; our %universed = (); our %world = (); sub queryProcesses { my $server = shift; my $found = 0; my @found; my $process = new Proc::ProcessTable(); my $processTableRecord; foreach $processTableRecord (@{$process->table}) { if ($processTableRecord->fname eq $server) { $found++; push @found, $processTableRecord; } } if ($found == 0) { %{$server} = ( status => "<font color=\"red\" face=\"Arial, Helvetica +, sans serif\">Down</font>", server => $server, action => "Start" ); } elsif ($found == 1) { %{$server} = ( status => "<font color=\"green\" face=\"Arial, Helveti +ca, sans serif\">Up</font>", PID => $found[0]->pid, server => $found[0]->fname, action => "Stop" ); #print $processTableRecord->uid, "\n"; } else { } } sub printStatusHTML { print $statusCGI->header( "text/html" ), $statusCGI->start_html( "chat.educ.foo.edu Administration" ); print <<EOHTML; <table align="center" border="0" cellspacing="1" cellpadding="2"> <tr><td colspan="5"> <font color="#000000" face="Arial, Helvetica, sans serif" size="+1"><b +>Server Stats</b></font> <font color="#000000" face="Arial, Helvetica, sans serif"> as of</font +> </td></tr> <tr><td bgcolor="#000077"> <form action="status.cgi" method="POST"> <font color="#FFFFFF" face="Arial, Helvetica, sans serif">Status</font +> </td><td bgcolor="#000077"> <font color="#FFFFFF" face="Arial, Helvetica, sans serif">Server</font +> </td><td bgcolor="#000077"> <font color="#FFFFFF" face="Arial, Helvetica, sans serif">Uptime</font +> </td><td bgcolor="#000077"> <font color="#FFFFFF" face="Arial, Helvetica, sans serif">User</font> </td><td bgcolor="#000077"> <font color="#FFFFFF" face="Arial, Helvetica, sans serif">PID</font> </td><td bgcolor="#000077"> <font color="#FFFFFF" face="Arial, Helvetica, sans serif">Action</font +> </td></tr> <tr><td bgcolor="#EEEEEE"> <font color="#000000" face="Arial, Helvetica, sans serif">$universed{s +tatus}</font> </td><td bgcolor="#EEEEEE"> <font color="#000000" face="Arial, Helvetica, sans serif">$universed{s +erver}</font> </td><td bgcolor="#EEEEEE"> <font color="#000000" face="Arial, Helvetica, sans serif"></font> </td><td bgcolor="#EEEEEE"> <font color="#000000" face="Arial, Helvetica, sans serif"></font> </td><td bgcolor="#EEEEEE"> <font color="#000000" face="Arial, Helvetica, sans serif">$universed{P +ID}</font> <input type="hidden" name="universedPID" value="$universed{PID}"> </td><td align="center" bgcolor="#EEEEEE"> <input type="hidden" name="universedAction" value="$universed{action}" +> <input type="submit" value="$universed{action}"> </form> </td></tr> <tr><td bgcolor="#f2eedb"> <form action="status.cgi" method="POST"> <font color="#000000" face="Arial, Helvetica, sans serif">$world{statu +s}</font> </td><td bgcolor="#f2eedb"> <font color="#000000" face="Arial, Helvetica, sans serif">$world{serve +r}</font> </td><td bgcolor="#f2eedb"> <font color="#000000" face="Arial, Helvetica, sans serif"></font> </td><td bgcolor="#f2eedb"> <font color="#000000" face="Arial, Helvetica, sans serif"></font> </td><td bgcolor="#f2eedb"> <font color="#000000" face="Arial, Helvetica, sans serif">$world{PID}< +/font> <input type="hidden" name="worldPID" value="$world{PID}"> </td><td align="center" bgcolor="#f2eedb"> <input type="hidden" name="worldAction" value="$world{action}"> <input type="submit" value="$world{action}"> </form> </td></tr> <tr><td colspan="5"> <font color="#000000" face="Arial, Helvetica, sans serif"><a href="htt +p://www.activeworlds.com/help/aw31/uniserver.html" target="_blank">Un +iserver Documentation</a> | <a href="http://www.activeworlds.com/help +/aw31/world.html" target="_blank">Worlds Server Documentation</a></fo +nt> </td></tr> </table> EOHTML print $statusCGI->end_html; } our $universedAction = $statusCGI->param("universedAction"); our $worldAction = $statusCGI->param("worldAction"); if ( $statusCGI->query_string eq "" ) { queryProcesses($universedBin); queryProcesses($worldBin); printStatusHTML(); } elsif ( $statusCGI->param("universedAction") eq "start") { die(print STDERR "Got to first elsif.") unless system("/usr/local/ +bin/universed start"); sleep 5; queryProcesses($universedBin); queryProcesses($worldBin); printStatusHTML(); ; } elsif ($statusCGI->param("universedAction") eq "stop") { die unless system("/usr/local/bin/universed stop"); sleep 5; queryProcesses($universedBin); queryProcesses($worldBin); printStatusHTML(); } elsif ($statusCGI->param("worldAction") eq "start") { die unless system("/usr/local/bin/world start"); sleep 5; queryProcesses($universedBin); queryProcesses($worldBin); printStatusHTML(); } elsif ($statusCGI->param("worldAction") eq "stop") { die unless system("/usr/local/bin/world stop"); sleep 5; queryProcesses($universedBin); queryProcesses($worldBin); printStatusHTML(); }
Thanks in advance to everyone.
dpatrick

In reply to This fails mysteriously everytime... by dpatrick

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (5)
    As of 2019-11-13 09:34 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Strict and warnings: which comes first?



      Results (70 votes). Check out past polls.

      Notices?