Solved

CGI Script Waiting forInput??

Posted on 1999-01-26
8
189 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
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…
The viewer will learn how to count occurrences of each item in an array.
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…

758 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

18 Experts available now in Live!

Get 1:1 Help Now