PHP shell_exec()

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
So I'm working on some PHP code here and I have the following:

$string = shell_exec("ps aux | grep ntp");

Basically just trying to find a certain running process (ntp as a filler right now).
I get the following error:

sh: ntp: command not found

No idea why it's doing that. Something about the pipe in the command seems to be making it angry. Has anyone run into this and knows a solution?
 

UndeadDragon

Super Moderator
Reaction score
447
Do other shell commands work on it? Is that the only one which won't work?
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Seems to work correctly on my system. Are you sure that the space between grep and ntp is really just a space and not a space + \r or something weird like that?

You can skip the pipe and do "ps -fC ntp" if getting a process by exec name is the only thing you want to do.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top