PHP shell tar问题,返回代码2 [英] PHP shell tar problem, return code 2
本文介绍了PHP shell tar问题,返回代码2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
要使用PHP中的tar归档文件夹:
Want to archive a folder using tar from PHP:
$result = shell_exec("tar cf $sourceFile $sourceFolder -C $source > /dev/null; echo $?");
var_dump($result);
输出:
string(2) "2 "
> /dev/null; echo $?
用于在linux下输出脚本的结果代码;
the > /dev/null; echo $?
thing is for outputing the result code of a script under linux;
-C $source
-在执行任何操作之前更改为正确的文件夹
the -C $source
- changes to the right folder before doing anything
这真的很奇怪,因为当我从linux控制台运行它时,它工作得很好-创建了归档文件,所以这不是权限问题.
This is really strange because when i run this from linux console, it works just fine - creates the archive, so it's not a permission issue.
"whoami"或"ls"之类的其他片段效果很好.
Other sripts like "whoami" or "ls" work fine.
任何想法是什么意思?
推荐答案
也许是:shell_exec("/bin/bash tar ....")
这篇关于PHP shell tar问题,返回代码2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文