newbie CGI question

Bobby Kleemann rkleeman at neta.com
Tue Feb 13 17:53:23 CST 2001


~sdpm~
Depending on how the program detects it's being run as a CGI you may be
able to trick it into running.  It probably detects the CGI environment
variables, so if you delete all the environment variables that your
webserver sets for CGI you might be able to get it to run.

 _ _ _
 Bobby Kleemann <rkleeman at neta.com>
     http://www.neta.com/~rkleeman/

On Tue, 13 Feb 2001, Todd Rockhold wrote:

> In case any other newbies out there care, I'll post this to the mail list.
> 
> Thanks to President Kleemann for the tip.
> 
> In fact, there was something from STDERR.  At first glance, the tpsa
> application program
> appears to have different license requirements for stand-alone versus cgi
> use. The text came out plain as
> day on the html form.  So this may not be a CGI programming problem per se.
> An unexpected wrinkle
> for my first try at CGI.  Oh, well...
> 
> > -----Original Message-----
> > From:	Bobby Kleemann [SMTP:rkleeman at neta.com]
> > Sent:	Tuesday, February 13, 2001 1:44 PM
> > To:	Todd Rockhold
> > Subject:	RE: newbie CGI question
> > 
> > Try putting this at the end of the qx() line, " 2>&1"
> > 
> > I think what's going on is something is being printed out on STDERR, which
> > the webserver is taking to be the begining of output, except the output
> > doesn't look like a typical CGI header (Content-type: text/html, ...).
> > 
> >  _ _ _
> >  Bobby Kleemann <rkleeman at neta.com>
> >      http://www.neta.com/~rkleeman/
> > 
> > On Tue, 13 Feb 2001, Todd Rockhold wrote:
> > 
> > > There are about 60 log files on the machine, but what appears to be the
> > > germane one contains (I replaced the IP address with "[IP address]" and
> > the
> > > path to my cgi script with "[path to my cgi script]"):
> > > 
> > > [13/Feb/2001:13:07:38] failure: for host [IP address] trying to POST
> > [path
> > > to my cgi script], cgi-parse-output reports: the CGI program [path to my
> > cgi
> > > script] did not produce a valid header (name without value: got line
> > > "****************************************************************")
> > > A simplified version of the script appears below.  With respect to my
> > > question, it exhibits the same behavior:
> > > 
> > > #!/usr/bin/perl -w
> > > use strict;
> > > 
> > > # use CGI;
> > > 
> > > $ENV{DY_LICENSE_DATA}="/usr/home/thor/v471/etc/dy_license.dat";
> > > $ENV{DY_ROOT}="/usr/home/thor/v471";
> > > $ENV{LD_LIBRARY_PATH}="/lib:/usr/lib:/usr/home/thor/v471/lib";
> > > 
> > > my %FORM;
> > > my $smiles = "Q";
> > > 
> > > print "Content-type:text/html\n\n";
> > > 
> > > my $buffer;
> > > read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> > > my @pairs = split(/&/, $buffer);
> > > foreach my $pair (@pairs) 
> > > {
> > >     my $name;
> > >     my $value;
> > >     ($name, $value) = split(/=/, $pair);
> > >     $value =~ tr/+/ /;
> > >     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> > >     $FORM{$name} = $value;
> > > }
> > > 
> > > 
> > > print "<html><head><title>Form Output</title></head><body>";
> > > print "<h2>Results from FORM post</h2>\n";
> > > 
> > > $smiles = $FORM{"SMILES"};
> > > 
> > > 
> > > foreach my $key (sort keys(%FORM)) 
> > > {
> > >     eval {print "$key = $FORM{$key}<br>"};
> > >     print "error: $@<br>" if $@;
> > > }
> > > 
> > > $smiles = "CCCCCC";
> > > my $result = qx(echo '$smiles' |
> > > /usr/home/thor/v471/contrib/src/c/tpsa/tpsa);
> > > print "</body></html>";
> > > > -----Original Message-----
> > > > From:	Bobby Kleemann [SMTP:rkleeman at neta.com]
> > > > Sent:	Tuesday, February 13, 2001 12:49 PM
> > > > To:	Todd Rockhold
> > > > Cc:	'san-diego-pm-list at happyfunball.pm.org'
> > > > Subject:	Re: newbie CGI question
> > > > 
> > > > ~sdpm~
> > > > What's the error message being printed out in the error_log?
> > > > 
> > > >  _ _ _
> > > >  Bobby Kleemann <rkleeman at neta.com>
> > > >      http://www.neta.com/~rkleeman/
> > > > 
> > > > On Tue, 13 Feb 2001, Todd Rockhold wrote:
> > > > 
> > > > > ~sdpm~
> > > > > I have a standalone perl script which runs fine but fails as a cgi
> > > > script
> > > > > (error 500: internal server error).
> > > > > 
> > > > > The culprit appears to be the following line:
> > > > > 
> > > > > 	    $result = qx(echo '$smiles' |
> > > > > /usr/home/thor/v471/contrib/src/c/tpsa/tpsa);
> > > > > 
> > > > > Attempt to trap the error with an eval{} block had no detectable
> > effect.
> > > > > 
> > > > > How do I do the equivalent in a CGI script?  
> > > > > What rule am I breaking?   
> > > > > What tutorials/documentation addresses running another program from
> > > > within a
> > > > > CGI script?
> > > > > ~sdpm~
> > > > > 
> > > > > The posting address is: san-diego-pm-list at hfb.pm.org
> > > > > 
> > > > > List requests should be sent to: majordomo at hfb.pm.org
> > > > > 
> > > > > If you ever want to remove yourself from this mailing list,
> > > > > you can send mail to <majordomo at happyfunball.pm.org> with the
> > following
> > > > > command in the body of your email message:
> > > > > 
> > > > >     unsubscribe san-diego-pm-list
> > > > > 
> > > > > If you ever need to get in contact with the owner of the list,
> > > > > (if you have trouble unsubscribing, or have questions about the
> > > > > list itself) send email to
> > <owner-san-diego-pm-list at happyfunball.pm.org>
> > > > .
> > > > > This is the general rule for most mailing lists when you need
> > > > > to contact a human.
> > > > > 
> > > > 
> > > > ~sdpm~
> > > > 
> > > > The posting address is: san-diego-pm-list at hfb.pm.org
> > > > 
> > > > List requests should be sent to: majordomo at hfb.pm.org
> > > > 
> > > > If you ever want to remove yourself from this mailing list,
> > > > you can send mail to <majordomo at happyfunball.pm.org> with the
> > following
> > > > command in the body of your email message:
> > > > 
> > > >     unsubscribe san-diego-pm-list
> > > > 
> > > > If you ever need to get in contact with the owner of the list,
> > > > (if you have trouble unsubscribing, or have questions about the
> > > > list itself) send email to
> > <owner-san-diego-pm-list at happyfunball.pm.org> .
> > > > This is the general rule for most mailing lists when you need
> > > > to contact a human.
> > > 
> 

~sdpm~

The posting address is: san-diego-pm-list at hfb.pm.org

List requests should be sent to: majordomo at hfb.pm.org

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.




More information about the San-Diego-pm mailing list