Jump to content

Recommended Posts

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.

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, #!

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.