mshreya has asked for the wisdom of the Perl Monks concerning the following question:

I think you are all right.. it was running the script properly from command line as it understood the Autosys command but from Apache server it was not. So I added an additional sourcing of Autosys from my wrapper CGI and it worked. thanks so much for your replies. I am not a perl expert at all.. Just learning.. so couldnt understand things clearly. thanks again for all the helpp.

I have problem with my CGI perl script. Below is the code i have post the table tag closure. Before this table, ofcourse I have the BODY tag still open.

# Autosys command @job_run = `autorep -J my_job_name -w`; print "<PRE><FONT SIZE=3>\n"; foreach $job_line (@job_run) { print "'$job_line'"; } print "</FONT></PRE>\n";
Command line output:
<PRE><FONT SIZE=3> Job Name Last +Start Last End ST Run Pri/Xit ________________________________________________________________ _____ +_______________ ____________________ __ _______ ___ my_job_name 02/05/2015 03:54:02 + ----- RU 70730069/1 </FONT></PRE> </CENTER></BODY></HTML>
the same code, i paste in HTML source, i see the display of this run details. But when I run this code in my frame on HTML page when I open the source and see, this is what I see:
<PRE><FONT SIZE=3> </FONT></PRE> </CENTER></BODY></HTML>
Please help.

Replies are listed 'Best First'.
Re: Html not printing my shell command output
by Happy-the-monk (Canon) on Feb 05, 2015 at 09:54 UTC

    @job_run = `autorep -J my_job_name -w`;

    Maybe your web server cannot access the "autorep" command the way you do when running it from a shell.

    You do access your page on a web server, don't you? Because your browser on its own does not know what to do with it.

    There will be an error log for the web server that should tell you what happened there and then.

    Cheers, Sören

    Créateur des bugs mobiles - let loose once, run everywhere.
    (hooked on the Perl Programming language)

      As I mentioned, I am getting the output of my Autorep command and this script is running fine in command line when I run like ./my_code.cgi. So I dont think that is the problem here. Not sure what else Iam missing here.

        "So I dont think that is the problem here."

        I don't think you understand what you have been told. While you can run this from the command line when logged in, this does not mean that your webserver can. Did you check your web server logs?

        As I mentioned, there is a difference in accessing a programme from the command line, or from a browser, or from a web server.

        It may be just as simple as the path to the executable not being in the environment of the web server.

        I have not seen you ruling it out yet.

        Cheers, Sören

        Créateur des bugs mobiles - let loose once, run everywhere.
        (hooked on the Perl Programming language)

Re: Html not printing my shell command output
by i5513 (Pilgrim) on Feb 05, 2015 at 09:54 UTC
    Hello, Does your error_log says anything ? I would save the autorep output on a file and see what is in the file when it is running via CGI:
    @job_run = `autorep -J my_job_name -w 2>&1 | tee /tmp/autorep.$$.output`;
    
    Maybe apache or your webserver has not the path to autorep program Regards,

    PD: Updated from ">" to "| tee" to " 2>&1 | tee"
Re: Html not printing my shell command output
by mshreya (Initiate) on Feb 05, 2015 at 10:41 UTC

    I think you are all right.. it was running the script properly from command line as it understood the Autosys command but from Apache server it was not. So I added an additional sourcing of Autosys from my wrapper CGI and it worked. thanks so much for your replies. I am not a perl expert at all.. Just learning.. so couldnt understand things clearly. thanks again for all the helpp.