search
Homephp教程php手册linux下用php执行shell命令查看服务器的机器名

linux下用php执行shell命令查看服务器的机器名

Jun 13, 2016 am 10:53 AM
linuxphpshellOrderimplementservermachineCheckofmeetneed

今天遇到一个小小的需求,

如何在网页中显示服务器的机器名,

在Ubuntu中只需输入命令:uname -n即可看到(Redhat也是一样),

于是想php能否直接调用shell命令来执行这个操作呢?

查阅资料之后,

得知确实有,而且有好几个:

popen

fpassthru

shell_exec

exec

system

看了下使用方法,

貌似shell_exec比较简单,只需传入命令作参数,

而且直接把执行完命令之后的结果返回来了,

所以试了下:

shell_exec('uname -n');

?>

成功地显示了当前服务器的机器名。

不过,如果是购买的服务器,就不一定能测试成功了,

因为出于安全考虑,可能服务器商会禁用掉它们中的一些或全部

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SecLists

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.