Linux uptime command inside php doesn't show anything -


I'm trying a Linux command for uptime in a php file on a server

 < code> & lt; P & gt; Uptime for this system & lt ;? Php $ up_time = shell_exec ('uptime'); Echo $ uptime; ? & Lt; / P & gt;   

But when I open my webpage it just shows:

  uptime for this system   

PHP is running in command if I go to command prompt and uptime, I can see the result.

I am doing SSH in a Linux webserver. The PHP file stays in my folder on the server.

I think the following code will work.

  uptime for this system & lt ;? php passthru ('/ usr / bin / uptime'); ? & Gt;   

To execute the system command in a PHP, I suggest that you always provide a full path to the command.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -