[英]PHP using ssh2_exec to execute script with parameters from query
我正在尝试从服务器执行脚本,该参数是从MySQL查询中检索并存储到$test
是否可以将其用作脚本的参数? 我还有一个存储在参数$script
<?php
include("db.php");
$user = 'user';
$password = 'pwd';
$script = '/my/path/to/script/script.sh';
...
$testResult = mysqli_query($dbConnection, $queryNextTest);
$test = $testResult->fetch_object()->test_script; //this is my parameter obtained from query
$stream = ssh2_exec($connection, $script); //how can I use test as my paramter to execute the
?>
所以我正在寻找的是这样的东西: $stream = ssh2_exec($connection, '/my/path/to/script/script.sh $test');
但是$test
不能在引号内。
您应该将引号更改为double并使用大括号来表示变量,如下所示:
$stream = ssh2_exec($connection, "{$script} {$test}");
甚至没有这样的花括号:
$stream = ssh2_exec($connection, "$script $test");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.