简体   繁体   English

我可以使php运行shell脚本吗?

[英]Can I make php run shell scripts?

What I want to do is create a small webpage with 3 links when a particular link is clicked it runs a particular ssh script through console 我想要做的是创建一个带有3个链接的小型网页,当单击特定链接时,它将通过控制台运行特定的ssh脚本

for example if I wanted to make "STOP" and when it's clicked it would go to a ssh script...say stop.sh and that would just have stop in it, this would stop the server. 例如,如果我要创建“ STOP”,然后单击它,它将转到ssh脚本...例如stop.sh,而该脚本只是在其中停止,这将停止服务器。

Is their an easy way to do this? 他们是这样做的简单方法吗?

Yes, You can run. 是的,您可以运行。 Following methods allows your to run commands in shell 以下方法允许您在shell中运行命令

  1. shell_exec 了shell_exec
  2. popen POPEN
  3. system 系统
  4. exec EXEC
  5. pcntl_exec pcntl_exec
  6. proc_open proc_open
  7. backtick (`) 反引号(`)

Invoking shell is not a good practice. 调用shell不是一个好习惯。 Try to use equivalent PHP functions. 尝试使用等效的PHP函数。

检查执行程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM