Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Could you perhaps show us how you run it from the command line?

This piece of code doesn't seem to do much yet (is it meant to be pseudo code?)

Things to think about:

  • Are you trying to run the executable remotely from another machine via CGI? and also pick up the file from off the web? (because this is what your file starting with "http://" makes it look like. If you want to do that I'd probably look at something like LWP::Simple - which makes it very easy to slurp in a file off the web.

    (Or were you meaning to tell the CGI the path to a file sitting on the same server as itself? - which is what your question seems to indicate. If so you would only need to give it the local path to the file as far as the CGI program was concerned (or more securely the name of a file sitting in a predetermined directory on the server where the program *always* looked for its files.)

  • Your script starts off with use CGI; indicating that it is intended to be run as a CGI program itself - is that what you really mean? to run one CGI which calls another CGI? Perhaps you actually intend to run one CGI which executes a file locally (i.e. on the same server as the CGI script) instead? - if so, you wouldn't need to call it with "http://" - but would probably want to run it locally using open and a pipe like this:
  • # path to program my $prog = '/local/path/to/cgi-bin/executableprog'; open(PROG, "| $prog") || die "Can't run '$prog': $!\n"; print PROG "$file\n"; close(PROG);
  • Presumably where you have:
    my $pid = open PIPE, "-|";
    and then:
    exec PROG or die "Cannot open pipe to executableprog: $!";
    PIPE and PROG were meant to be talking about the same process?
  • What's the stuff for a fork for? you're probably better off not worrying about forking (which is a little complex) until you get the basics of reading and writing files and running programs mastered.

In reply to Re: running an executable from a cgi script by serf
in thread running an executable from a cgi script by Angharad

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2023-02-08 18:10 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (43 votes). Check out past polls.