Solved

CGI Script Waiting forInput??

Posted on 1999-01-26
8
191 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
 
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
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: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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
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 modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
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…

910 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

19 Experts available now in Live!

Get 1:1 Help Now