Solved

CGI Script Waiting forInput??

Posted on 1999-01-26
8
200 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
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.

 
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
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 how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

829 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