I am trying to execute a script from a server, the parameter is retrieved from MySQL query and stored into $test
is there a way to use this as a parameter for my script? I have a script stored in a parameter as well $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
?>
So what I am looking for is something like this: $stream = ssh2_exec($connection, '/my/path/to/script/script.sh $test');
but the $test
cannot be inside the quotes.
You should change the quote to double and use curly bracket to express your variable like this:
$stream = ssh2_exec($connection, "{$script} {$test}");
Or even without curly braces like this:
$stream = ssh2_exec($connection, "$script $test");