Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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 ./runthis.pl 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)


Comment on Re: output of one program doesn't show in another on server
Select or Download Code
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 runthis.pl
    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 runthis.pl : 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/runthis.pl`;

    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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009287]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2015-07-30 08:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls