【发布时间】:2014-11-25 05:22:32
【问题描述】:
如果从带有变量的 php 运行,命令将不起作用。但是,如果我从终端或不带变量的 php(exec 或 shell_exec)运行它,它就可以工作。 这不起作用:
$command = 'lftp -c "open -u'.$user.','.$password.' -p xxx sftp://xx.xx.xx.xx; put -O /folder1 folder2/'.$fileName.';"';
exec($command);
var_dump(shell_exec($command)) -> 打印:NULL
这行得通:
$command = 'lftp -c "open -u user,password -p 6710 sftp://xx.xx.xx.xx; put -O /folder1 folder2/file.txt;"';
exec($command);
谢谢
【问题讨论】:
-
有很多类似的问题。我建议搜索。例如:*.com/questions/8527817/…、*.com/questions/6780285/…、*.com/questions/20107147/…等