Reputation: 167
I need to execute a gcloud coumpute ssh --command via php (I'll check on security later).
Whether I use exec, shell_exec or Symfony Process, the command crashes:
Example with Symfony process (same goes with exec or shell_exec), simple ls
command used for testing:
$process = new Process("/path/to/google-cloud-sdk/bin/gcloud compute ssh my-instance --command='ls' ");
$process->run();
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();
if (!$process->isSuccessful()) {
}
I am getting the following error :
gcloud crashed (AttributeError): 'NoneType' object has no attribute 'split'
Please note that the same command, copied-pasted directly in CLI, works perfectly.
Any hint please ?
Upvotes: 1
Views: 307
Reputation: 1776
Here is the explanation to what happening, $_ENV does not actually set an environment variable, i.e. the variable will not propagate to any child processes you launch (except forked script processes, in which case it's just a variable in the script's memory) This explanaed Here.
Upvotes: 0