Run the shell command in php in linux to view the server's machine name_php tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.