This is a discussion on Problems with exec within the PHP Language forums, part of the PHP Programming Forums category; I'm having a problem with exec on my hosting server. Unfortunately, the hosting support seems to be anything but ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I'm having a problem with exec on my hosting server. Unfortunately,
the hosting support seems to be anything but helpful. The following works fine on my localhost: <?php $MaskData = "mask.exe -e \"TestString\""; $Result = exec($MaskData, $Output, $ReturnValue); echo("Result: ".$Result); echo("ReturnValue: ".$ReturnValue."<br/>"); foreach($Output as $outputline) { echo("outputline: $outputline<br>"); } ?> But on my hosting server, I've installed (I believe) the properly compiled version for that os, and it always returns 127. I don't have shell access, so I'm a bit of loss on how to proceed. Any information on this return code or how to work through this, would be greatly appreciated. Thanks, J |
|
|||
|
JahMic wrote:
> I'm having a problem with exec on my hosting server. Unfortunately, > the hosting support seems to be anything but helpful. > > The following works fine on my localhost: > > <?php > $MaskData = "mask.exe -e \"TestString\""; > > $Result = exec($MaskData, $Output, $ReturnValue); > echo("Result: ".$Result); > echo("ReturnValue: ".$ReturnValue."<br/>"); > > foreach($Output as $outputline) > { > echo("outputline: $outputline<br>"); > } > ?> > > But on my hosting server, I've installed (I believe) the properly > compiled version for that os, and it always returns 127. I don't have > shell access, so I'm a bit of loss on how to proceed. Any > information on this return code or how to work through this, would be > greatly appreciated. > > Thanks, J Hi J, If you cannot execute in a shell, do a phpinfo(), and find the following settings: safe_mode = On or Off and safe_mode_exec_dir = Is safe_mode maybe On, and is your mask.exe not listed in safe_mode_exec_dir? If so, you know why you cannot execute mask.exe. Read more here: http://nl3.php.net/manual/en/function.phpinfo.php Bottomline: Talk with your hosting provider. If they do not cooperate, switch hosting provider or do not use mask.exe. Regards, Erwin Moller |
|
|||
|
On Nov 27, 7:14 pm, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.com> wrote: > JahMic wrote: > > I'm having a problem with exec on my hosting server. Unfortunately, > > the hosting support seems to be anything but helpful. > > > The following works fine on my localhost: > > > <?php > > $MaskData = "mask.exe -e \"TestString\""; > > > $Result = exec($MaskData, $Output, $ReturnValue); > > echo("Result: ".$Result); > > echo("ReturnValue: ".$ReturnValue."<br/>"); > > > foreach($Output as $outputline) > > { > > echo("outputline: $outputline<br>"); > > } > > ?> > > > But on my hosting server, I've installed (I believe) the properly > > compiled version for that os, and it always returns 127. I don't have > > shell access, so I'm a bit of loss on how to proceed. Any > > information on this return code or how to work through this, would be > > greatly appreciated. > > > Thanks, J > > Hi J, > > If you cannot execute in a shell, do a phpinfo(), and find the following > settings: > > safe_mode = On or Off > and > safe_mode_exec_dir = > > Is safe_mode maybe On, and is your mask.exe not listed in > safe_mode_exec_dir? > > If so, you know why you cannot execute mask.exe. > > Read more here:http://nl3.php.net/manual/en/function.phpinfo.php > > Bottomline: Talk with your hosting provider. If they do not cooperate, > switch hosting provider or do not use mask.exe. > > Regards, > Erwin Moller Hi Erwin, Thanks for the quick reply. safe mode is actually off. This application is in the same directory as the scripts. If I change $MaskData = "mask.exe -e \"TestString\""; to $MaskData = "./mask.exe - e \"TestString\""; (the addition of ./) the value of $ReturnValue is 1 and no values for $Result and $output. (Output should be a long string). A hosting provider switch is likely, but this is an immediate issue that I need to get taken care. Once again, any help is much appreciated. Thanks, J |
|
|||
|
JahMic wrote:
> On Nov 27, 7:14 pm, Erwin Moller > <Since_humans_read_this_I_am_spammed_too_m...@spam yourself.com> wrote: >> JahMic wrote: >>> I'm having a problem with exec on my hosting server. Unfortunately, >>> the hosting support seems to be anything but helpful. >>> The following works fine on my localhost: >>> <?php >>> $MaskData = "mask.exe -e \"TestString\""; >>> $Result = exec($MaskData, $Output, $ReturnValue); >>> echo("Result: ".$Result); >>> echo("ReturnValue: ".$ReturnValue."<br/>"); >>> foreach($Output as $outputline) >>> { >>> echo("outputline: $outputline<br>"); >>> } >>> ?> >>> But on my hosting server, I've installed (I believe) the properly >>> compiled version for that os, and it always returns 127. I don't have >>> shell access, so I'm a bit of loss on how to proceed. Any >>> information on this return code or how to work through this, would be >>> greatly appreciated. >>> Thanks, J >> Hi J, >> >> If you cannot execute in a shell, do a phpinfo(), and find the following >> settings: >> >> safe_mode = On or Off >> and >> safe_mode_exec_dir = >> >> Is safe_mode maybe On, and is your mask.exe not listed in >> safe_mode_exec_dir? >> >> If so, you know why you cannot execute mask.exe. >> >> Read more here:http://nl3.php.net/manual/en/function.phpinfo.php >> >> Bottomline: Talk with your hosting provider. If they do not cooperate, >> switch hosting provider or do not use mask.exe. >> >> Regards, >> Erwin Moller > > Hi Erwin, > > Thanks for the quick reply. safe mode is actually off. Good. This > application is in the same directory as the scripts. If I change > $MaskData = "mask.exe -e \"TestString\""; to $MaskData = "./mask.exe - > e \"TestString\""; (the addition of ./) the value of $ReturnValue is 1 > and no values for $Result and $output. (Output should be a long > string). > Ok, the $ReturnValue says 1, so I expect that the command DID run succesfully. Very strange your $Output array is empty. Of course, what you want now is run the command by hand in a shell as user PHP, being on Apache: Apache, or nobody or www-data, or IUSR_<machinename> on IIS. But you cannot. So you'll have to debug by guessing. Does the mask.exe has execution rights for PHP-user? Do you maybe use files in mask.exe that are not accecible by PHP? Throw in a full path to mask.exe instead of ./ Check your slashes, etc. Try passthru() instead of exec(). And last but not least, insult the supportdepartment of your hosting provider. ;-) Good luck. Regards, Erwin Moller > A hosting provider switch is likely, but this is an immediate issue > that I need to get taken care. Once again, any help is much > appreciated. > > Thanks, J > |
|
|||
|
Hi Erwin, Once again thanks for the help. More comments below:
On Nov 27, 8:20 pm, Erwin Moller <Since_humans_read_this_I_am_spammed_too_m...@spam yourself.com> wrote: > JahMic wrote: > > On Nov 27, 7:14 pm, Erwin Moller > > <Since_humans_read_this_I_am_spammed_too_m...@spam yourself.com> wrote: > >> JahMic wrote: > >>> I'm having a problem with exec on my hosting server. Unfortunately, > >>> the hosting support seems to be anything but helpful. > >>> The following works fine on my localhost: > >>> <?php > >>> $MaskData = "mask.exe -e \"TestString\""; > >>> $Result = exec($MaskData, $Output, $ReturnValue); > >>> echo("Result: ".$Result); > >>> echo("ReturnValue: ".$ReturnValue."<br/>"); > >>> foreach($Output as $outputline) > >>> { > >>> echo("outputline: $outputline<br>"); > >>> } > >>> ?> > >>> But on my hosting server, I've installed (I believe) the properly > >>> compiled version for that os, and it always returns 127. I don't have > >>> shell access, so I'm a bit of loss on how to proceed. Any > >>> information on this return code or how to work through this, would be > >>> greatly appreciated. > >>> Thanks, J > >> Hi J, > > >> If you cannot execute in a shell, do a phpinfo(), and find the following > >> settings: > > >> safe_mode = On or Off > >> and > >> safe_mode_exec_dir = > > >> Is safe_mode maybe On, and is your mask.exe not listed in > >> safe_mode_exec_dir? > > >> If so, you know why you cannot execute mask.exe. > > >> Read more here:http://nl3.php.net/manual/en/function.phpinfo.php > > >> Bottomline: Talk with your hosting provider. If they do not cooperate, > >> switch hosting provider or do not use mask.exe. > > >> Regards, > >> Erwin Moller > > > Hi Erwin, > > > Thanks for the quick reply. safe mode is actually off. > > Good. > > This > > > application is in the same directory as the scripts. If I change > > $MaskData = "mask.exe -e \"TestString\""; to $MaskData = "./mask.exe - > > e \"TestString\""; (the addition of ./) the value of $ReturnValue is 1 > > and no values for $Result and $output. (Output should be a long > > string). > > Ok, the $ReturnValue says 1, so I expect that the command DID run > succesfully. Actually, on successful systems $ReturnValue is 0. > Very strange your $Output array is empty. Is there a possible way to pipe or redirect the output? > > Of course, what you want now is run the command by hand in a shell as > user PHP, being on Apache: Apache, or nobody or www-data, or > IUSR_<machinename> on IIS. > > But you cannot. > > So you'll have to debug by guessing. > Does the mask.exe has execution rights for PHP-user? I've tried 777 to no avail. > Do you maybe use files in mask.exe that are not accecible by PHP? No other files > Throw in a full path to mask.exe instead of ./ to no avail? > Check your slashes, etc. > Try passthru() instead of exec(). nada > And last but not least, insult the supportdepartment of your hosting > provider. ;-) Don't worry about that, I'm giving them their due share of grieve. Thanks, James > > Good luck. > > Regards, > Erwin Moller > > > > > A hosting provider switch is likely, but this is an immediate issue > > that I need to get taken care. Once again, any help is much > > appreciated. > > > Thanks, J- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text - |
|
|||
|
JahMic wrote:
>>> application is in the same directory as the scripts. If I change >>> $MaskData = "mask.exe -e \"TestString\""; to $MaskData = "./mask.exe - >>> e \"TestString\""; (the addition of ./) the value of $ReturnValue is 1 >>> and no values for $Result and $output. (Output should be a long >>> string). >> Ok, the $ReturnValue says 1, so I expect that the command DID run >> succesfully. > > Actually, on successful systems $ReturnValue is 0. Oops. Sorry for the confusion. > >> Very strange your $Output array is empty. > > Is there a possible way to pipe or redirect the output? Well, passthru() should do this. <quote> The passthru() function is similar to the exec() function in that it executes a command . This function should be used in place of exec() or system() when the output from the Unix command is binary data which needs to be passed directly back to the browser. A common use for this is to execute something like the pbmplus utilities that can output an image stream directly. By setting the Content-type to image/gif and then calling a pbmplus program to output a gif, you can create PHP scripts that output images directly. </quote> > >> Of course, what you want now is run the command by hand in a shell as >> user PHP, being on Apache: Apache, or nobody or www-data, or >> IUSR_<machinename> on IIS. >> >> But you cannot. >> >> So you'll have to debug by guessing. >> Does the mask.exe has execution rights for PHP-user? > > I've tried 777 to no avail. clear. > >> Do you maybe use files in mask.exe that are not accecible by PHP? > > No other files Anything else that might need additional rights? Maybe opening ports under 1024 on *nix? > >> Throw in a full path to mask.exe instead of ./ > > to no avail? :-( > >> Check your slashes, etc. >> Try passthru() instead of exec(). > > nada > >> And last but not least, insult the supportdepartment of your hosting >> provider. ;-) > > Don't worry about that, I'm giving them their due share of grieve. > Sorry James, What you really need to do first is run the program from commandline to see if it actually works. You don't know for sure the program works. Is that right? But I understand that is not possible, since you don't have shell. :-/ I think I would try the supportdepartment and ask then to try it for you. Give them the command and ask them to run it for you. If they refuse, shoot them. :P It is very difficult to debug like this of course. Sorry, I am also out of options. Good luck! Regards, Erwin Moller > Thanks, James > >> Good luck. >> >> Regards, >> Erwin Moller >> >> >> >>> A hosting provider switch is likely, but this is an immediate issue >>> that I need to get taken care. Once again, any help is much >>> appreciated. >>> Thanks, J- Hide quoted text - >> - Show quoted text -- Hide quoted text - >> >> - Show quoted text - > |
|
|||
|
On Nov 28, 5:37 am, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.com> wrote: > JahMic wrote: > >>> application is in the same directory as the scripts. If I change > >>> $MaskData = "mask.exe -e \"TestString\""; to $MaskData = "./mask.exe - > >>> e \"TestString\""; (the addition of ./) the value of $ReturnValue is 1 > >>> and no values for $Result and $output. (Output should be a long > >>> string). > >> Ok, the $ReturnValue says 1, so I expect that the command DID run > >> succesfully. > > > Actually, on successful systems $ReturnValue is 0. > > Oops. Sorry for the confusion. > > > > >> Very strange your $Output array is empty. > > > Is there a possible way to pipe or redirect the output? > > Well, passthru() should do this. > > <quote> > The passthru() function is similar to the exec() function in that it > executes a command . This function should be used in place of exec() or > system() when the output from the Unix command is binary data which > needs to be passed directly back to the browser. A common use for this > is to execute something like the pbmplus utilities that can output an > image stream directly. By setting the Content-type to image/gif and then > calling a pbmplus program to output a gif, you can create PHP scripts > that output images directly. > </quote> > > > > >> Of course, what you want now is run the command by hand in a shell as > >> user PHP, being on Apache: Apache, or nobody or www-data, or > >> IUSR_<machinename> on IIS. > > >> But you cannot. > > >> So you'll have to debug by guessing. > >> Does the mask.exe has execution rights for PHP-user? > > > I've tried 777 to no avail. > > clear. > > > > >> Do you maybe use files in mask.exe that are not accecible by PHP? > > > No other files > > Anything else that might need additional rights? > Maybe opening ports under 1024 on *nix? > > > > >> Throw in a full path to mask.exe instead of ./ > > > to no avail? > > :-( > > > > >> Check your slashes, etc. > >> Try passthru() instead of exec(). > > > nada > > >> And last but not least, insult the supportdepartment of your hosting > >> provider. ;-) > > > Don't worry about that, I'm giving them their due share of grieve. > > Sorry James, > > What you really need to do first is run the program from commandline to > see if it actually works. > > You don't know for sure the program works. Is that right? > > But I understand that is not possible, since you don't have shell. :-/ > > I think I would try the supportdepartment and ask then to try it for you. > Give them the command and ask them to run it for you. > If they refuse, shoot them. :P > > It is very difficult to debug like this of course. > Sorry, I am also out of options. > > Good luck! > > Regards, > Erwin Moller > > > Thanks, James > > >> Good luck. > > >> Regards, > >> Erwin Moller > > >>> A hosting provider switch is likely, but this is an immediate issue > >>> that I need to get taken care. Once again, any help is much > >>> appreciated. > >>> Thanks, J- Hide quoted text - > >> - Show quoted text -- Hide quoted text - > > >> - Show quoted text - What if you tried using exec to run the command but piping standard out to one file and standard error to another file. Make sure both of these files are in your home directory - and then use fopen to read them. This probably won't help tooooo much but it might give you some insight. Good luck! |
|
|||
|
On Nov 29, 9:13 pm, Aaron Saray <102degr...@102degrees.com> wrote:
> On Nov 28, 5:37 am, Erwin Moller > > > > > > <Since_humans_read_this_I_am_spammed_too_m...@spam yourself.com> wrote: > >JahMicwrote: > > >>> application is in the same directory as the scripts. If I change > > >>> $MaskData = "mask.exe -e \"TestString\""; to $MaskData = "./mask.exe - > > >>> e \"TestString\""; (the addition of ./) the value of $ReturnValue is 1 > > >>> and no values for $Result and $output. (Output should be a long > > >>> string). > > >> Ok, the $ReturnValue says 1, so I expect that the command DID run > > >> succesfully. > > > > Actually, on successful systems $ReturnValue is 0. > > > Oops. Sorry for the confusion. > > > >> Very strange your $Output array is empty. > > > > Is there a possible way to pipe or redirect the output? > > > Well, passthru() should do this. > > > <quote> > > The passthru() function is similar to the exec() function in that it > > executes a command . This function should be used in place of exec() or > > system() when the output from the Unix command is binary data which > > needs to be passed directly back to the browser. A common use for this > > is to execute something like the pbmplus utilities that can output an > > image stream directly. By setting the Content-type to image/gif and then > > calling a pbmplus program to output a gif, you can create PHP scripts > > that output images directly. > > </quote> > > > >> Of course, what you want now is run the command by hand in a shell as > > >> user PHP, being on Apache: Apache, or nobody or www-data, or > > >> IUSR_<machinename> on IIS. > > > >> But you cannot. > > > >> So you'll have to debug by guessing. > > >> Does the mask.exe has execution rights for PHP-user? > > > > I've tried 777 to no avail. > > > clear. > > > >> Do you maybe use files in mask.exe that are not accecible by PHP? > > > > No other files > > > Anything else that might need additional rights? > > Maybe opening ports under 1024 on *nix? > > > >> Throw in a full path to mask.exe instead of ./ > > > > to no avail? > > > :-( > > > >> Check your slashes, etc. > > >> Try passthru() instead of exec(). > > > > nada > > > >> And last but not least, insult the supportdepartment of your hosting > > >> provider. ;-) > > > > Don't worry about that, I'm giving them their due share of grieve. > > > Sorry James, > > > What you really need to do first is run the program from commandline to > > see if it actually works. > > > You don't know for sure the program works. Is that right? > > > But I understand that is not possible, since you don't have shell. :-/ > > > I think I would try the supportdepartment and ask then to try it for you. > > Give them the command and ask them to run it for you. > > If they refuse, shoot them. :P > > > It is very difficult to debug like this of course. > > Sorry, I am also out of options. > > > Good luck! > > > Regards, > > Erwin Moller > > > > Thanks, James > > > >> Good luck. > > > >> Regards, > > >> Erwin Moller > > > >>> A hosting provider switch is likely, but this is an immediate issue > > >>> that I need to get taken care. Once again, any help is much > > >>> appreciated. > > >>> Thanks, J- Hide quoted text - > > >> - Show quoted text -- Hide quoted text - > > > >> - Show quoted text - > > What if you tried using exec to run the command but piping standard > out to one file and standard error to another file. Make sure both of > these files are in your home directory - and then use fopen to read > them. This probably won't help tooooo much but it might give you some > insight. Good luck!- Hide quoted text - > > - Show quoted text - As it turns out, after blindly switching binaries, I found out I was trying to use a binary for a different OS. (too many flavors of unix) Of course, if I had shell access, I could have found this out in 5 minutes. Onwards to other problems. Many thanks for all the help, J |