$which aws 我得到: /usr/local/bin/aws . 但是,如果我试图在php脚本中运行这个命令,它什么也不做。
$which aws
/usr/local/bin/aws
$cmd ="aws --version"; try { $exec = exec($cmd,$output, $return); $exec2 = shell_exec($cmd); } catch(Exception $e) { echo 'Message: ' .$e->getMessage(); }
exec2 返回空exec返回127。
exec2
现在我知道这是一个路径问题,我试图将它添加到路径中,但它不起作用。
我知道这可以使用php sdk完成,但由于各种原因,我不能使用它。
有人能解释一下如何用php在ubuntu 18.04上运行吗?
我的代码一直在工作。问题是,我必须在命令末尾使用2>&1将stdout重定向到stderr。
$cmd = "aws redshift restore-table-from-cluster-snapshot --cluster-identifier {$this->redshift_cluster_identifier} --snapshot-identifier {$this->snapshot_identifier} --source-database-name citnow --source-table-name {$tableName} --target-database-name citnow --new-table-name {$newTableName} 2>&1"; $exec = exec($cmd,$output, $return);