php运行的exec命令与当前目录不同

发布于 2025-02-12 12:22:48 字数 642 浏览 0 评论 0原文

我有两个在共享主机上运行的代码。我从这里帖子收到了两个代码。第一个工作,但第二个没有。我正在尝试获得第二块工作,因为我不想使用CHDIR更改当前的工作目录。我尝试了许多不同的组合,但它们都没有起作用。

<?php

chdir('/user/bin/ghostscript');

$a = '/home1/user/public_html/a.pdf';
$b = '/home1/user/public_html/b.pdf';

exec('gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=1 -dLastPage=2 -sOutputFile='.$b.' '.$a);

?>

这无效:

<?php

$a = '/home1/user/public_html/a.pdf';
$b = '/home1/user/public_html/b.pdf';

exec('cd /user/bin/ghostscript && ./gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=1 -dLastPage=2 -sOutputFile='.$b.' '.$a);

?>

I have two block of codes running on a shared host. I got both codes from posts here. First one worked but the second didn't. I am trying to get the 2nd block work as I don't want to use chdir to change my current working directory. I have tried many different combinations but none of them worked.

<?php

chdir('/user/bin/ghostscript');

$a = '/home1/user/public_html/a.pdf';
$b = '/home1/user/public_html/b.pdf';

exec('gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=1 -dLastPage=2 -sOutputFile='.$b.' '.$a);

?>

This didn't work:

<?php

$a = '/home1/user/public_html/a.pdf';
$b = '/home1/user/public_html/b.pdf';

exec('cd /user/bin/ghostscript && ./gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=1 -dLastPage=2 -sOutputFile='.$b.' '.$a);

?>

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文