I have written snippet to execute code in remote machine using ssh2_exec
and command execution works fine . I want to set some environmental variables. But when I pass them as ssh2_exec
params I'm getting this warning and the environmental variables are not getting set. Please advice
PHP Warning: ssh2_exec(): Failed setting DEBIAN_FRONTEND=noninteractive on
remote end in Setup.php on line 405
My code
$env_vars = array(
'DEBIAN_FRONTEND' => 'noninteractive'
);
$stream = ssh2_exec($con, escapeshellcmd($command), null , $env_vars);
Work around
set environmental variables by using export command, along with command.
Eg: export DEBIAN_FRONTEND=noninteractive; apt-get install -y mysql-server