Dragoa Posted June 9, 2008 Share Posted June 9, 2008 Hi, I'm currently trying to set up a PHP page to call and run a PERL script using PHP 5.2.6 running off of Apache 2 on an HP-UX 11 box. The PERL script is a tool used in a different area whose functionality is required to make the website work, so redoing it isn't really an option, but whenever I call the script, or any script with a #! character in it the script fails and doesn't give me any meaningful error message. [The only one I get is the one I programmed in myself] So I'm wondering if there's something special I need to do to execute this? Currently I am doing this: $cmd = "/path/to/script" exec($cmd, $result, $output) And the $result value comes out to be 2, while the code I am modifying expects it to be a 0(I have no idea if this is a valid value or not, it's just what the designer put in there). Any thoughts would be greatly appreciated. Next, I would like to access some Shell Variables from PHP(Mostly stuff that is being set-up for a user, pathnames etc.) but I have no idea on how to do this(I've tried echoing a shell_exec command which calls a variable, and I can get ls commands, and other stuff to work but still no variables). Is there something special I need to do to set-up these variables? [Note: I've got an env script that basically contains all the variables I'd like set, so if possible I can run that one] Sorry if this is a bit confusing, but I'm finding it a bit hard to properly explain what I want it to do. Any questions about either bits, just ask. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/109412-php-executing-perl-script-and-shell-question/ Share on other sites More sharing options...
MadTechie Posted June 9, 2008 Share Posted June 9, 2008 the *SheBang isn't used by Perl when it run is run on windows, linux should be okay.. your need to look at the perl code to workout what the error levels mean, 0 normally means all is okay, you should get the returned value from the $output ie print_r($output); * AKA HashBang, SharpBang, #! Quote Link to comment https://forums.phpfreaks.com/topic/109412-php-executing-perl-script-and-shell-question/#findComment-561236 Share on other sites More sharing options...
effigy Posted June 9, 2008 Share Posted June 9, 2008 What's in $output? Does this script run properly outside of PHP? See this for environment variables. Quote Link to comment https://forums.phpfreaks.com/topic/109412-php-executing-perl-script-and-shell-question/#findComment-561246 Share on other sites More sharing options...
Dragoa Posted June 9, 2008 Author Share Posted June 9, 2008 Erk, I got my variables backwards...it's exec($cmd, $output, $result), sorry about that. Eitherway: $result is 2, and $output is an array which when printed with print_r gives me: Array( ) The script runs properly outside of PHP yes, haven't tried the exact command although I will do that right now... And it runs perfectly. Also as a side note: Yesterday I tried running a script which was just an ls command with a #!, and the ls didn't work where it previously had. And thanks for the link, I will look through that. Quote Link to comment https://forums.phpfreaks.com/topic/109412-php-executing-perl-script-and-shell-question/#findComment-561257 Share on other sites More sharing options...
effigy Posted June 9, 2008 Share Posted June 9, 2008 Does/Should the script output anything? What do the docs say in regards to its return values? Quote Link to comment https://forums.phpfreaks.com/topic/109412-php-executing-perl-script-and-shell-question/#findComment-561264 Share on other sites More sharing options...
Dragoa Posted June 9, 2008 Author Share Posted June 9, 2008 There is some text output returned to standard output, but it's redirected to a file. Quote Link to comment https://forums.phpfreaks.com/topic/109412-php-executing-perl-script-and-shell-question/#findComment-561286 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.