linux下用php执行shell命令查看服务器的机器名
今天遇到一个小小的需求,
如何在网页中显示服务器的机器名,
在Ubuntu中只需输入命令:uname -n即可看到(Redhat也是一样),
于是想php能否直接调用shell命令来执行这个操作呢?
查阅资料之后,
得知确实有,而且有好几个:
popen
fpassthru
shell_exec
exec
system
看了下使用方法,
貌似shell_exec比较简单,只需传入命令作参数,
而且直接把执行完命令之后的结果返回来了,
所以试了下:
shell_exec('uname -n');
?>
成功地显示了当前服务器的机器名。
不过,如果是购买的服务器,就不一定能测试成功了,
因为出于安全考虑,可能服务器商会禁用掉它们中的一些或全部

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
