Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Calling a method inside CGI script using system calls

by Anonymous Monk
on Sep 28, 2000 at 18:50 UTC ( #34398=categorized question: print w/replies, xml ) Need Help??
Contributed by Anonymous Monk on Sep 28, 2000 at 18:50 UTC
Q&A  > CGI programming


When I call the run_actuals method in Unix Server. It ran a file named web.template and output the result to the file web.template.output. This is exactly what i typed in unix server:
( /GPP/bin/run_actuals web.template & )
in case you wanted to know, the file web.template is in cgi-bin. It works perfect. But I could not run the same method from inside my cgi script. The command I gave to call and run the file is this:
system("/GPP/bin/run_actuals /GPP/web/cgi-bin/web.template");
I moved the web.template file away from cgi-bin and tried to run it again. but I still could run the method inside my CGI script.
I don't understand why I can run the same method manually on the Unix Server, but I cannot run it from my CGI script...
Thanks in advance, if you know the answer

Answer: Calling a method inside CGI script using system calls
contributed by Fastolfe

I would check some of the following:

  • Ownership and/or permissions issues
    Just because you're able to telnet in and execute a program, or read a certain file, doesn't mean that your web server will be able to do the same. Typically web servers run as a restricted user (such as "nobody") so that they can't be tricked into overwriting files in important places, or reading something they shouldn't be able to read. Check to be sure your script has appropriate permissions (typically octal 755) to be run by the general public. Perl scripts should be executable *and* readable.
  • Current working directory
    Probably not an issue in this case, since your web.templates file is in your cgi-bin directory and you're explicitely specifying the path to your other binary. In many cases, though, this is an oversight. CGI scripts are typically executed with a CWD of the CGI directory.
  • Environment settings
    If your script depends upon certain environment settings to execute correctly, be sure those are set up or worked around in your CGI script. Specifically, if your script executes other apps or programs in your path, be sure your PATH is set up correctly (and explicitely, don't just append) to locate these other scripts, or specify an absolute path to the other binary you wish to execute.
  • If all else fails, check your error logs
    Most binaries print things to STDERR when they fail. If this is running under your CGI script, you may not see the error messages in your browser (though if you're using the CGI module, check out CGI::Carp).
Answer: Calling a method inside CGI script using system calls
contributed by Jouke

I presume it has something to do with the permissions-thing. The user under which the script runs is not the same as your user when you manually run the program.

You should ajust the permissions for the program and the template it uses...

Answer: Calling a method inside CGI script using system calls
contributed by Anonymous Monk

I changed all the dirctories and files that my program uses to 777. But it is still not working

Please (register and) log in if you wish to add an answer

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (4)
    As of 2020-08-09 15:11 GMT
    Find Nodes?
      Voting Booth?
      Which rocket would you take to Mars?

      Results (54 votes). Check out past polls.