Single quoted command. OK in test, fails in CGI
Posted by enquirer (enquirer), 3 November 2004I am attempting to write some perl using the perl cgi.pm module. I cannot get it to display string variable values on a web page. I can only display text that I type explicitly.
For example, in the code below, The output to the screen is:
HELLOHELLO THERE!!!How are youu ''
Notice that it places the '' as concatenated with $temp, but does print the value of $temp as well.
Can you help me
Posted by admin (Graham Ellis), 3 November 2004I had a bit of "fun" with that too.
Turned out to be the path to getproj_2 / permissions on it.
Although you probably tested the script under your user account (and so with your permissions and your path), when run by the web server it's run with the permissisons and environment of that server, which are probably different. I persuaded it to functions by checking that there were permissions for getproj_2 to execute as the server and by specifying a complete path to it. Here's the code I ended up with:
and I had the following in getproj_2 ...
Posted by admin (Graham Ellis), 3 November 2004(This follow up later ... in case the above solution didn't work)
I took my (working) example and moved getproj_2 into a subdirectory and it worked fine. I then changed the permissions on that subdirectory to "700" and it worked fine in debug mode and failed in "live" mode just as you described. Changed it back to 755 again, worked again.
You might also like to check the $? variable after the call - it's returns the status of the command run in backtics and you should get 0 if it suceeds and a code (I get -1) if it failed to run ... in the case just above due to permissions.
Finally, you it might be worth you looking in your getproj_2 to see if it uses environment variables and / or the "-t" operator on STDIN or STDOUT to see if they're interactive devices.
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho