Run the shell command in php in linux to view the server name.

Source: Internet
Author: User
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 wonder if php can directly call the shell command to execute this operation? After reading the information, I learned that there is indeed, and there is good... syntaxHighlighter. all (); how to display the server's machine name on the webpage is a small demand today. in Ubuntu, you only need to enter the command: uname-n to see it (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: popenfpassthrushell_execexecsystem. after reading the usage method, it seems that shell_exec is relatively simple. just input the command as a parameter, in addition, the result after the command is executed is directly returned, so I tried: <? Phpshell_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, because for security reasons, the server may disable some or all of them.

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.