0

I am try to execute some command trough php. like kill {process id} Those command works fine using putty command prompt but same thing if i use with php its nothing happen .

2
  • Add the PHP code you're attempting to execute.
    – xyz
    May 23, 2015 at 6:27
  • $command="kill ".$pieces[1]; //p($command); passthru($command); May 23, 2015 at 6:27

1 Answer 1

1

The shell command you're trying to execute will run with the permissions of the process running the PHP binary ( I.e. apache , etc...) When you're logged in via putty/ssh, the kill command has your permissions.

Unless you suexec the PHP /apache or are trying to kill a process owned by the same user as that running the PHP/apache, you're not going to have much luck.

2
  • what to do for run this from php ? May 23, 2015 at 10:20
  • I presented two methods in my answer. Use suexec to change the sync ownership of process to kill or run the process that you want to manage with the same user that runs PHP. Ultimately the limits placed are supposed to be there for system security. If this is running on a shared host, much of this will be prohibited from a security stand point.
    – sparq
    May 23, 2015 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.