PHP shell tar 问题,返回码2 [英] PHP shell tar problem, return code 2

查看:33
本文介绍了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 "

<代码>>/开发/空;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"等其他 sript 也可以正常工作.

Other sripts like "whoami" or "ls" work fine.

任何想法是什么意思?

推荐答案

也许:shell_exec("/bin/bash tar ....")

这篇关于PHP shell tar 问题,返回码2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆