?
Solved

CGI Script Waiting forInput??

Posted on 1999-01-26
8
Medium Priority
?
215 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
[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
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
Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

 
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 300 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

801 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