Jump to content

Running a Korn Script from PHP


Dragoa

Recommended Posts

I'm using PHP 5.2.6, with an Apache2 server running off of a HP-UX 11 box, and I'm trying to call a korn script[pretty sure it's a korn script] from PHP, but it fails and errors out at the line "#!/bin/ksh -n"[so right at the beginning, I'm positive it's this line, since I have this line and this line only in another file and it still returns an error]

 

The error status I get is 138, I have no idea what this means[if anyone has a list of what the PHP exit statuses are I'd be greatly appreciative, I constantly get these exit statuses and I have no idea what they mean and I can't seem to find anything online that has a list of what these things are...]

 

Also: If I remove the "#!/bin/ksh -n" from the script, it runs fine.

 

Any help?

Link to comment
Share on other sites

I didn't write the script I'm calling, I can't really modify it without going through the process of modifying the rest of the scripts to do the same thing. Besides I have a hunch that whatever this problem is will arise again soon as I do a proper starting of my apache server(#!/usr/bin/perl wasn't working before, but now it magically started working)

Link to comment
Share on other sites

On the box I'm running the server off of korn is installed, but I haven't installed korn to the Apache Server itself.

 

Whatever that meens. Is korn installed on the server 9the machine I meen) or not? And if it is, is it located in /bin ?

Link to comment
Share on other sites

I'm using box to mean the machine that runs programs(while you seem to be using server for this). And I'm using server in reference to the Apache Client itself[just clarifying this to make further communication a bit easier].

 

But to respond again. My computer does have KSH installed, and it is located correctly. Permissions look like they're fine for the ksh file. I have not compiled/configured Apache in any special way to actually run KSH specifically.

 

PHP Page[Just the line that calls the code, everything before and after it is just functionality for the page and has no interaction with this line]:

 

echo passthru("/users/dwloader/lee/web/tmp/job_env2", $result);

 

job_env2:

#!/bin/ksh -n
print "Hi";

 

Removing the #!/bin/ksh -n line from job_env2 gives me the proper result[$result = 0 here]. While right now it just fails and returns and $result  = 138.

Link to comment
Share on other sites

I'm using box to mean the machine that runs programs(while you seem to be using server for this). And I'm using server in reference to the Apache Client itself[just clarifying this to make further communication a bit easier].

 

Yeah sorry, I refer to the entire machine running services (apache) as a server.

 

With the information you have provided its my opinion that this isn't at all a php issue. PHP is passing execution to your shell just fine, hence your recieving a shell error and not a php one.

 

Can you execute this script from a terminal without issue?

Link to comment
Share on other sites

Yes, just tried it and it functions just fine.

 

Although it seems adding the flag -n causes it to do nothing, which is odd considering the script I'm trying to run runs whenever I open up a new x-term window and sets up my environment and it works just fine there. But I tried removing the -n flag and running it from the PHP page again and still nothing, $result is still 138.

Link to comment
Share on other sites

Tried exec, turns out that I might be able to straight up remove the #!/bin/ksh line, but I'd prefer not to since whenever I add more functionality it requires a lot of changing.

 

Alright from my user terminal I get: /bin/ksh

 

Using an exec command from a PHP Page I get: /usr/bin/ksh

 

Both of these files exist, both are the same when compared via a comp.

 

Also some testing that was done yesterday: renaming the sh file to ksh, netted a successful running with #!/bin/ksh. So it seems to me that there is something in ksh that is not agreeing with PHP.

Link to comment
Share on other sites

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.