【发布时间】:2023-03-06 18:58:01
【问题描述】:
我需要使用exec 依次运行 2 个命令,但它不会运行。
代码
$command1 = 'cd '.$destination.''; //open destination folder (e.g. public_html)
$command2 = 'git clone '.$repos->repository.''; //make clone
$sshConnection1 = exec($command1); // run first command(open folder)
$sshConnection = exec($command2); //run second command (make clone)
在我创建这个问题之前,我阅读了一些建议的主题,例如 this one。添加"&" 等,但没有运气。
请告诉我应该怎么做才能成功运行这两个命令。
【问题讨论】:
-
@Amessihel 但他们不会,我用
dd($sshConnection1);检查了第一个命令,它返回false -
exec("cd $destination && git clone ...")怎么样 -
@KarstenKoop 谢谢老兄,它有效,请分享它作为答案,我会接受它