Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: output of one program doesn't show in another on server

by mbethke (Hermit)
on Dec 18, 2012 at 06:47 UTC ( #1009287=note: print w/replies, xml ) Need Help??

in reply to output of one program doesn't show in another on server

What AnomalousMonk said. What happens there is that length evaluates @ret in scalar context which gives either 0 or 1 and then takes the length of this string which is 1 in both cases.

Your real problem though is one with the working directory as Apache doesn't change it to that where the CGI lives so ./ is not found. Try an absolute path or FindBin (ISTR the latter had some problems with CGI environments as well but it's worth a try)

Replies are listed 'Best First'.
Re^2: output of one program doesn't show in another on server
by gideondsouza (Pilgrim) on Dec 18, 2012 at 16:25 UTC

    Thanks a million for your help guys

    1. I do have #!/usr/bin/perl on the top of my
    2. I'm running on RHEL/Apache2 on an AmazonEC2 instance.

    I updated my code according to NetWallah and AnonymousMonk's suggestions, I get the following error as predicted:

    Error running : No such file or directory at /var/www/html/abc.cgi line 15

    My files are in this path : /var/www/html , this is where I've configured apache to run .cgi and .pl scripts. I changed my line like this:

    my @ret = `\usr\bin\perl /var/www/html/`;

    No Luck, still says No such file or directory.

    1. Forgive my stupidity here, is my absolute path formed wrong?
    2. I didn't quite understand how I should use the FindBin module mbethke mentions. Any clues here would be awesome. Thanks!

       qx// `` (backticks) is double-quotish-interpolating, so  \usr\bin\perl is really:

      >perl -wMstrict -le "print qq{'\usr\bin\perl'}; " Unrecognized escape \p passed through at -e line 1. 'Sinperl'

      (Were you using warn-ings?)

      Update: Oops... Fixed example code to include initial backslash. (And always, always avoid Sinperl!)

        Thanks very much for your reply. Forgive me but I don't fully understand your answer though. Should I trying using qx instead of backticks?
        Hey thanks so much. It works in the end. I updated the original post (top post) with my findings. Thanks so much.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009287]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2018-05-27 14:39 GMT
Find Nodes?
    Voting Booth?