Solved

problem using iframe in perl script

Posted on 2004-10-29
767 Views
Last Modified: 2011-10-03
Hi,

I get this error,

----------------------------------------
502 Bad Gateway
The CGI was not CGI/1.1 compliant
----------------------------------------
when I use my cgi script.

The script basiclly consists of code plus some HTML output as follows
-------------------------------------------------------------------------------------
cgi code

print <<ENDHTML;
<html><head><title>Agreement</title></head>
<body>
some html text here
<iframe src="agreement.html" name="subscriber_agreement"></iframe>
some more html text here
</body></html>
ENDHTML
---------------------------------------------------------------------------------------

The cgi script loads just fine and dandy, but inside the Iframe, I get the above error.  
The code that is in the agreement.html is simple text nothing fancy, which loads just fine in it's own window.

I'm using a Linux box with the Boa Web Server.  

I'm really baffeled with this one, it's as if you cannot use and iframe in a cgi document.

Thanks for any help.
-air




0
Question by:Airgazm
    6 Comments
     
    LVL 7

    Expert Comment

    by:rugdog
    did you print the HTTP header at the beginning?, since not all your code is posted. But you should have a line like the following before sending the HTML code:

    print "content-type: text/html\n\n";

    0
     
    LVL 10

    Expert Comment

    by:Luxana
    Strict CGI output compliance can be enabled and disabled using the [CgiStrictOutput] configuration directive. With it disabled the server will accept any output from the script, if not CGI or NPH compliant then it automatically generates plain-text header. When enabled, if not a CGI or NPH header the server returns a "502 Bad Gateway" error. For debugging scripts generating this error introduce a plain-text debug mode and header, or use the WATCH facility's CGI item
    0
     

    Author Comment

    by:Airgazm
    yeah, all that's there as far as header.

    I just got it to work by changing the agreement.html file into a .pl file and adding the necessarry cgi stuff to the .pl file, now it shows in the I frame just fine.

    So, now I know it works as a .pl file but not as a .html file.

    keep in mind, I have my www root directory set to /cgi-bin/

    I ran some new test code that fails,
    -------------------------------------------
    test.pl
    -------------------------------------------
    #!/usr/bin/perl
    use CGI;
    use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

    print "Content-type:text/html\n\n";
    print <<ENDHTML;
    <html><head><title>title</title></head>
    <body>
    test
    <iframe src='agreement.html' name='agreement'></iframe>
    </body>
    </html>
    ENDHTML
    --------------------------------------------------------------------
    agreement.html
    ---------------------------------------------------------------------
    <html>
    <head><title>Agreement</title></head>
    <body>
    test
    </body></html>
    ----------------------------------------------------------------------

    Thanks
    -air

    0
     
    LVL 10

    Expert Comment

    by:Luxana
    #!/usr/bin/perl
    use CGI;
    use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

    print "Content-type:text/html\n\n";

    print qq`

    <html><head><title>title</title></head>
    <body>
    test
    <iframe src='../agreement.html' name='agreement'></iframe>
    </body>
    </html>
    `;


    ---------------
    this is working for me...where agreement.html is in /var/www and test.pl is /usr/lib/cgi-bin


    0
     
    LVL 10

    Accepted Solution

    by:
    or if you want do it your way :

    #!/usr/bin/perl
    use CGI;
    use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

    print "Content-type:text/html\n\n";
    print <<ENDHTML
    <html><head><title>title</title></head>
    <body>
    test
    <iframe src='../agrim.html' name='agreement'></iframe>
    </body>
    </html>
    ENDHTML

    ------

    do not use ";" in line with print <<ENDHTML
    0
     

    Author Comment

    by:Airgazm
    Well it seems it was because I was running the Iframe .html page out of the cgi-bin directory.

    I put the .html file for the iframe into /var/www and everything worked just fine.

    Thanks for the help
    -air

    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Title # Comments Views Activity
    Expect & sshpass package for Solaris 10 x86 15 759
    stftime format 4 44
    Perl string replace for refred url 9 42
    PERL - Find newest folder 12 70
    Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
    Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

    884 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