http://www.perlmonks.org?node_id=1010557


in reply to Help required for CGI Script
in thread CGI Script Working fine from my command prompt but Shows Internal server error when called through browser

When you run it via a browser, does your script return "Hello, World!" to the browser, and does the file "/tmp/ac.txt" contain what you expected? Do you see the word "HI"? What does that file contain (what is the expected output from "autostatus -J aa-test-bx-dly")?

Since you are using "fatalsToBrowser", are you seeing any error messages? What do they say?

Your code only tries to print the first line of "/tmp/ac.txt" to the browser, but if the output begins with a blank line, that's all your program will send to the browser.

If the autostatus output contains angle brackets, then your browser will be trying to interpret it as HTML tags, and will probably not display any of it (because the data can't be parsed that way). In order to see the "autostatus" output presented, you may have to print a <pre> tag before printing the command output, and then print a </pre> tag afterwards.

Replies are listed 'Best First'.
Re^2: Help required for CGI Script
by Anonymous Monk on Dec 28, 2012 at 07:46 UTC
    The output expected is RUNNING or SUCCESS .. Also the file so created doesnt have any blank lines. Please guide me the solution. Thanks
      The solution is that you debug your program using the advice and links already provided in reply to your several posts. If you're unable or unwilling to do so consider speaking to your manager or team leader explaining the situation. Consider the code you've actually written, what it does and what you're attempting to do. Your "expected output" does not occur within your program. http://learn.perl.org, tutorials.
        I hav gone through all the links but havenot got the Solution.
      Also the output is

      Content-Type: text/html; charset=ISO-8859-1 Hello, world! HI TEST JOB aa-test-bx-dly