-1

I received error :The server encountered an internal error and was unable to complete your request.Error message: End of script output before headers: inputcgi.cgi

Please let me know what could be the reason for this? I have tried adding and deleting some lines but nothing helps... The Cgi files are running correctly except these ones..

    #!"c:\xampp\perl\bin\perl.exe"


    use strict;
    use warnings;
    use CGI qw(:all); 

    my $cgi= new CGI;
    my $this_url=$cgi->url();
    my $cr=$cgi->param("cr");
    print $cgi->header();

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

    print << EndofHTML;

    <html>
        <head><link rel="stylesheet" type="text/css" href="style.css">
        <link href="CalendarControl.css"
          rel="stylesheet" type="text/css">
        <script src="CalendarControl.js"
            language="javascript"></script><script src="inputvalidation.js"></script> </head>
        <title>Baseline Automation-Inputs </title>

        <body>
        <font face = "Calibri">
            <div class="divtop"><img src="logo.jpg" </div>
            <div class="head"><h2><font color = "white"><b>TI Patch Request </b></font><h2></div>



        &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                If you have already submitted a request, Click on this button. <a href="google.com" target="_blank">Track Application status </a></td><br><br><br>
            <form name="input" method="POST" action="$this_url">
            &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<i> Fields marked with asterisk <font color="red">*</font>  are compulsory</i>
            <div class="divtable">
            <table cellpadding="3" cellspacing="5">
            <tr>
                <td></td>
                <td>Operating System<font color = red>*</font></td>
                <td><input type="radio" name="ostype" id="windows" onclick="checkno()" >Windows</td>
                <td><input type="radio" name="ostype" id="linux" onclick="checkyes()">Linux</td>
                <td><font color="red"><span id="enteros"></font></span></td>
            </tr>
            <tr>
            </tr>
            <tr>
                <td></td>
                <td>Patch Date and Time<font color = red>*</font></td>
                <td><input name="todays_date"
                        onfocus="showCalendarControl(this);"
                        type="text" style="width:100px;"></td>
    </tr>
            <tr>
                <td></td>
                <td>Server Name <font color = red>*</font></td>
                <td><span title="Press the 'ctrl' key to select multiple servers"><select name="serverlist" id="slist" size="4" multiple>
                        <option value="" disabled selected>Select servers</option>
                        <option>Server 1</option>
                        <option>Server 2</option>
                        <option>Server 3</option>
                        <option>Server 4</option>
                        <option>Server 5</option>
                    </select></span>
                </td>
                <td><font color="red"><span id="enterlist"></font></span></td>
            </tr>
            <tr>
            </tr>

            <tr>
                <td></td>
                <td>Frequency<font color = red>*</font></td>
                <td><input type="radio" name="frequency" id="biannual" onclick="checkcondition()">Biannual</td>
                <td rowspan><input type="radio" name= "frequency" id="monthly" onclick="checkcondition()">Monthly</td>
                <td><font color="red"><span id="enterfreq"></font></span></td>
            </tr>
            <tr>
            </tr>
            <tr>
                <td></td>
                <td>Snapshot Required?<font color = red>*</font></td>
                <td><input type="radio" name="snap" id="yes">Yes</td>
                <td><input type="radio" name="snap" id="no">No</td> 


            </tr>

        <tr>
            </tr>
            <tr>
                <td></td>
                <td>Baseline Update duration<font color = red>*</font></td>
                <td> <input type="radio" name="update" id="one">1 hour</td>
                <td> <input type="radio" name="update" id="two">2 hours</td>
                <td>  <input type="radio" name="update" id="four">4 hours</td>
                <td><font color="red"><span id="enterhour"></font></span></td>
            </tr>
            <tr>
            </tr>
            <tr>
                <td></td>
                <td>Change Request </td>
                <td><input type="text" name="cr" id="cr" maxlength="6" style="width:100px;"></td>
            </tr>

            <tr>
            </tr>
            <tr>
            <td></td>

                <td>Description</td>
                <td colspan="5"> <textarea rows="5" cols="40" placeholder="Enter any comments or queries" align="center"></textarea></td>
            </tr>

             <tr>
            </tr>
            <tr>
                <td></td>
                <td style="word-wrap: break-word;">E-mail (in case you want to    <br> receive notifications)</td>
                <td><input type ="text" name="email" style="width:150px;" onfocus=" " onBlur="ValidateEmail()"> </td>
                <td><font color="red"><span id="invalidemail"></font></span></td>
            </tr>

            </table></div>
            <br> <br> 



                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp

                <input type="button" name="prev" id="prev" value="<<Prev"> 
                <input type="button" name="save" id="save" value="Save" onClick="blank()">
                <input type="button" name="next" id="next" value="Next>>">

            <br>
            <br><br>
            <div class="head"><h2><font color = "white"><b>Selected Request</b></font><h2></div><br> <br> 
            &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
            <input type = "submit" value ="Submit Request" name="submit">


            </form></font>
            <p>The cr you entered was '$cr'</p> 
        </body>
        </html> 
        EndofHTML
        #So this was the code.
Sanjay
  • 29
  • 1
  • 8
  • Obligatory link to https://stackoverflow.com/questions/2165022/how-can-i-troubleshoot-my-perl-cgi-script . I recommend the section on "Try sending errors to the browser" – mob Jan 18 '18 at 18:22
  • Note that the HTML entity ` ` must be terminated by a semicolon `;` – Borodin Jan 18 '18 at 22:40

2 Answers2

3

If you search for perl cgi internal error you will see that for CGI scripts, it is usually required to look into the error log. This will show you the actual error that happened.

In this case you have an error in the so called here-document. Read about it in perldoc perlop, look for <<EOF.

   print <<EOF;
The price is $Price.
EOF
   print << "EOF"; # same as above
The price is $Price.
EOF

Note that the label of the here-doc, EOF, must come directly after the <<. You can only use a space if you explicitly use a quoted label.

At the end of the document the marker must be at the beginning of the line.

tinita
  • 3,987
  • 1
  • 21
  • 23
1

In another answer you have the explanation of what is wrong with your code. This is for a more general case.

As a general rule, it is always a good idea to use the library CGI::Carp (see here) while you are debugging your CGI scripts. It will send any errors to the browser screen instead of getting them in an error log.

This will work for errors reported with croak, confess, carp, warn and die. The last two will come from the use of those Perl instructions or from errors coming from Perl itself; the others will come from using the library Carp, which is what most CPAN libraries use to report problems to any calling scripts.

So you place use CGI::Carp; under use CGI and enjoy. If you only want to catch die, you may use use CGI::Carp qw(fatalsToBrowser);.

Once you have debugged your script, remember to remove the use of this library as it gives too much information for a potential attacker to have.

Javier Elices
  • 2,066
  • 1
  • 16
  • 25