dppxp79175 2013-03-05 05:05
浏览 106
已采纳

从PHP执行scanimage命令

I am brand new to PHP and I am trying to execute a shell command to initiate a command line scan on my Ubuntu 12.10 box:

I have the following piece of code in my php file (inside submit click handler):

shell_exec('scanimage --format=pdf > scan.pdf')

Is this even possible? I have been able to execute other terminal commands through this API. However in this case nothing happens. I am able to run the above command in a terminal window

I am trying to do the scan on form submit

<form method="post" action="printApp.php">
    <input type="submit" name="scan" value="Start New Scan" />

</form>



  <?
     if(isset($_POST["scan"])){
        shell_exec('scanimage --format=pdf > scan.pdf')
     }
    ?>
  • 写回答

1条回答 默认 最新

  • duanhunlou7051 2013-03-05 05:08
    关注

    Create a new php file called scanimage.php and put just

    <?php
    shell_exec('scanimage --format=pdf > scan.pdf');
    ?>
    

    in it. Then at bash type php scanimage.php while in the same directory as the file.

    UPDATE: After doing a chat it seems that Apache didn't have the permissions needed to access the scanner somewhere in /dev.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办