2

I have written snippet to execute code in remote machine using ssh2_execand 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);
Harikrishnan
  • 9,688
  • 11
  • 84
  • 127

1 Answers1

0

Work around

set environmental variables by using export command, along with command.

Eg: export DEBIAN_FRONTEND=noninteractive; apt-get install -y mysql-server
Harikrishnan
  • 9,688
  • 11
  • 84
  • 127