Run the shell command in php in linux to view the server name. Today, we have a small requirement: how to display the server's machine name on the webpage. in Ubuntu, you only need to enter the command uname-n to see it (Redhat is the same ), so I wondered if php could meet a small demand today,
How to display the server machine name on a webpage,
In Ubuntu, you only need to enter the command uname-n to see (Redhat is the same ),
So I wonder if php can directly call the shell command to execute this operation?
After reading the information,
I learned that there are indeed, and there are several:
Popen
Fpassthru
Shell_exec
Exec
System
After reading the usage method,
It seems shell_exec is relatively simple. you only need to input the command as a parameter,
And the result after the command is executed is returned directly,
So I tried:
<? Php
Shell_exec ('uname-n ');
?>
The machine name of the current server is displayed successfully.
However, if the server is purchased, the test may not be successful,
For security reasons, the server may disable some or all of them.
Ghost, how to display the server's machine name on the webpage, in Ubuntu, you only need to enter the command: uname-n to see (Redhat is the same), so I wonder if php can be straight...