简体   繁体   English

通过PHP链接SSH命令

[英]Chaining SSH commands via PHP

I am running a SSH2 command via PHP and am trying to chain the commands to answer the password prompts from the bash script I run. 我正在通过PHP运行SSH2命令,并试图链接命令以回答我运行的bash脚本的密码提示。

wget url-to-bash-script
bash name-of-file.sh

After this it will prompt for 在此之后,它将提示您

MySQL Password:

And: 和:

Retype password:

It will then proceed to install the packages for LAMP 然后它将继续为LAMP安装软件包

I have tried something like this with no luck; 我没有运气就尝试过这样的事情。

$ssh->exec( "wget URL;bash installLAMP.sh; password; password"); $ ssh-> exec(“ wget URL; bash installLAMP.sh; password; password”);

Thanks! 谢谢!

What you might want to use is expect 您可能想使用的是预期的

Here are some examples on how to use it: 以下是一些有关如何使用它的示例:

http://www.thegeekstuff.com/2010/10/expect-examples/ http://www.thegeekstuff.com/2010/10/expect-examples/

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

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