php运行的exec命令与当前目录不同
我有两个在共享主机上运行的代码。我从这里帖子收到了两个代码。第一个工作,但第二个没有。我正在尝试获得第二块工作,因为我不想使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论