通过 PHP 调用 tar 时,-C 选项被忽略

发布于 2024-09-17 17:51:41 字数 329 浏览 2 评论 0原文

如果我从 shell 运行 PHP 文件,那么 tar 命令将提取到我所在的目录,而不是我使用 -C 指定的目录。

我的命令是

passthru("tar xvf $file $tarfile/application $tarfile/application_detail $tarfile/application_device_type $tarfile/genre_application -C /var/www/vhosts/httpdocs/fred"); 

如何让它将特定文件提取到指定的目标目录?

文件名为 filename.tgz

If I run my PHP file from the shell, then the tar command extracts to the directory I am in, rather than the one I specified using -C

My command is

passthru("tar xvf $file $tarfile/application $tarfile/application_detail $tarfile/application_device_type $tarfile/genre_application -C /var/www/vhosts/httpdocs/fred"); 

How can I have it extract the specific files to the specified destination directory?

The filename is filename.tgz

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巡山小妖精 2024-09-24 17:51:41

目前您有:

tar xvf tarfile paths... -C target

将参数的顺序更改为:

tar xvf tarfile -C target paths...

At the moment you have:

tar xvf tarfile paths... -C target

Change the order of the arguments to:

tar xvf tarfile -C target paths...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文