Solved

CGI Script Waiting forInput??

Posted on 1999-01-26
8
209 Views
Last Modified: 2013-12-25
I am testing a CGI script.  I get an error when running from the browser, and from the command line it only goes into offline mode when I hit Ctrl-C.
How do I determine what is causing it to wait for user input?
Are there any good development environments where I can step through cgi scripts and watch the values of my variables?
0
Comment
Question by:chonsp
8 Comments
 

Expert Comment

by:andropov
ID: 1832407
Can you post the code of your script?
0
 

Author Comment

by:chonsp
ID: 1832408
I have a few USE and Require statements and it may get  messy.

I was hoping for more generalities of what kinds of statements. Would put the cgi script into a waiting for input mode.


0
 

Author Comment

by:chonsp
ID: 1832409
I have figured out the offending perl module by trial and error.  Again, I am looking for a more generic method.  maybe redirecting stdout or stderr??
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 7

Expert Comment

by:jconde
ID: 1832410
No, you can not redirect stderr....it won't work!

Check the following out:  The Method type you're using in your cgi.

- That you're printing "Content-Type: text/html\n\n" out.
-That you have no (;;) loops in you're coding

Can you post the code up in order for us to see what's wrong?

Regards,
Jorge
0
 

Author Comment

by:chonsp
ID: 1832411
Jorge,

You hit on part of the problem, I did have a "Content-Type.." issue.

The real problem cam from the following line:
   system ("/usr/xpg4/bin/grep -qx $SYBSERVER /ms/dist/syb/interfaces");
On my web-server $SYBSERVER was not initializing properly (OK on my UNIX workstation).  grep was then waiting for input.  I changed the line to below and I now get the behavior I want (I added some lines so you could see what I was doing with the result.
   system ("/usr/xpg4/bin/grep -qx \"$SYBSERVER\" /ms/dist/syb/interfaces");
   if ($? != 0) {  # If it can't find the server use the  prod server
          $SYBSERVER = "$SYBPRODSERVER";
          $SYBDBNAME = "$SYBPRODDB";
   }
OK, so let me modify my question somewhat.  Are there any good development environments for cgi scripts so I can step through my code and see the values of variables as I run the code?
0
 

Author Comment

by:chonsp
ID: 1832412
Edited text of question
0
 

Accepted Solution

by:
jvarsoke earned 100 total points
ID: 1832413
I don't believe the Content-type issue will make your CGI hang from the command line, though it would produce a Server Error in the Browser.

Most likely the program hangs b/c it's waiting for STDIN to read the variables from the FORM (HTML).  This is true if you are using something like  CGI.pm.  

But since you are no longer concerned with that aspect of your problem...

a good environemnt for debugging perl CGI code is Emacs.  There is a Perl Debugger Plug-in and Perl overlay to give you funky color coding to your Perl keywords.  Good stuff.

Other than that, the command line and a print statement are pretty good.

Also for debugging CGI code it's valuable to make a batchfile/script to set all your ENV variables so that they are the same as the Server's.  You can find out what they are by writing a short perl script to just throw back the env data to your browser.
##something like this
#!/share/apl/perl/bin/perl
 
&another_test;
 
sub another_test {
use CGI qw(:cgi-lib);
 
$query = new CGI;
 
print "Content-type: text/html\n\n";
 
print "<HTML><BODY>";
 
do_work($query);
sub do_work {
    my($query) = @_;
    my(@values,$key);
 
    print "<H2>Here are the current settings in this form</H2>";
 
    foreach $key ($query->param) {
        print "<STRONG>$key</STRONG> -> ";
        @values = $query->param($key);
        print join(", ",@values),"<BR>\n";
    }
}
 


0
 

Author Comment

by:chonsp
ID: 1832414
Thanks for the post about EMACS and your other comments.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
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…
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…
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 …

730 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