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 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址