Dragoa Posted June 13, 2008 Share Posted June 13, 2008 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 https://forums.phpfreaks.com/topic/110113-running-a-korn-script-from-php/ Share on other sites More sharing options...
jonsjava Posted June 13, 2008 Share Posted June 13, 2008 why not run it as /bin/bash, instead of ksh? bash is the standard. Dumb question, but I was just wondering.... Link to comment https://forums.phpfreaks.com/topic/110113-running-a-korn-script-from-php/#findComment-565082 Share on other sites More sharing options...
Dragoa Posted June 13, 2008 Author Share Posted June 13, 2008 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 https://forums.phpfreaks.com/topic/110113-running-a-korn-script-from-php/#findComment-565089 Share on other sites More sharing options...
Dragoa Posted June 16, 2008 Author Share Posted June 16, 2008 *bump* Link to comment https://forums.phpfreaks.com/topic/110113-running-a-korn-script-from-php/#findComment-566509 Share on other sites More sharing options...
trq Posted June 16, 2008 Share Posted June 16, 2008 If the shebang (#!/bin/ksh) line is giving you grief then it is likely the korn is not installed on the server. Is it? Link to comment https://forums.phpfreaks.com/topic/110113-running-a-korn-script-from-php/#findComment-566544 Share on other sites More sharing options...
Dragoa Posted June 16, 2008 Author Share Posted June 16, 2008 On the box I'm running the server off of korn is installed, but I haven't installed korn to the Apache Server itself. Link to comment https://forums.phpfreaks.com/topic/110113-running-a-korn-script-from-php/#findComment-566554 Share on other sites More sharing options...
trq Posted June 16, 2008 Share Posted June 16, 2008 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 https://forums.phpfreaks.com/topic/110113-running-a-korn-script-from-php/#findComment-566565 Share on other sites More sharing options...
DyslexicDog Posted June 16, 2008 Share Posted June 16, 2008 How are you running the script from php? Show code please... Link to comment https://forums.phpfreaks.com/topic/110113-running-a-korn-script-from-php/#findComment-566574 Share on other sites More sharing options...
Dragoa Posted June 16, 2008 Author Share Posted June 16, 2008 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 https://forums.phpfreaks.com/topic/110113-running-a-korn-script-from-php/#findComment-566583 Share on other sites More sharing options...
trq Posted June 16, 2008 Share Posted June 16, 2008 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 https://forums.phpfreaks.com/topic/110113-running-a-korn-script-from-php/#findComment-566618 Share on other sites More sharing options...
Dragoa Posted June 16, 2008 Author Share Posted June 16, 2008 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 https://forums.phpfreaks.com/topic/110113-running-a-korn-script-from-php/#findComment-566627 Share on other sites More sharing options...
Dragoa Posted June 17, 2008 Author Share Posted June 17, 2008 *bump* New twist in the puzzle! I can run #!/bin/sh but not #!/bin/ksh Link to comment https://forums.phpfreaks.com/topic/110113-running-a-korn-script-from-php/#findComment-567293 Share on other sites More sharing options...
DyslexicDog Posted June 17, 2008 Share Posted June 17, 2008 Have you tried using exec() since you are only collecting a return string and not binary data? Link to comment https://forums.phpfreaks.com/topic/110113-running-a-korn-script-from-php/#findComment-567407 Share on other sites More sharing options...
trq Posted June 17, 2008 Share Posted June 17, 2008 Can you login and type... which ksh in a term? What is the output? Link to comment https://forums.phpfreaks.com/topic/110113-running-a-korn-script-from-php/#findComment-567466 Share on other sites More sharing options...
Dragoa Posted June 17, 2008 Author Share Posted June 17, 2008 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 https://forums.phpfreaks.com/topic/110113-running-a-korn-script-from-php/#findComment-567473 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.