Note that there are some explanatory texts on larger screens.

plurals
  1. POScanning with scanimage from php from a linux host
    primarykey
    data
    text
    <p>Here's what the situation is: I am trying to use PHP to call <code>scanimage</code> on a Linux host, then save the resulting file to a web directory for future use.</p> <p>The below code produces no errors, but when I check out the /tmp directory, file.pnm is blank, and the scanner never starts. </p> <pre><code>&lt;?php require('/var/www/olin/includes/functions.php'); $con = connect_db(); //setup the POST variables if (isset($_POST['submit'])) { $fname = mysqli_real_escape_string($con, $_POST['fname']); $lname = mysqli_real_escape_string($con, $_POST['lname']); $license_no = mysqli_real_escape_string($con, $_POST['license_no']); $comments = mysqli_real_escape_string($con, $_POST['comments']); } if ($license_no == '') { $license_no = "None on File"; } if ($fname == '' || $lname == '') { echo '&lt;h1 class="message"&gt;Can\'t submit visitor: you are missing information!&lt;/h1&gt;'; } else { //setup the query and prepare it for exection $query= "insert into visitors (fname, lname, license_no, redsheet, comments)" . " values (?, ?, ?, 'Allow', ?) on duplicate key update fname = values(fname)," . "lname = values(lname), license_no = values(license_no), redsheet = values(redsheet)," . "comments = values(comments)"; $stmnt= mysqli_prepare($con, $query); //bind the statement parameters to variables mysqli_stmt_bind_param($stmnt, "ssss", $fname, $lname, $license_no, $comments ); //execute, then close the statment if (!mysqli_stmt_execute($stmnt)) { echo "Failed to ececute the query: " . mysqli_error($con); header('Refresh: 10; url=http://localhost/olin/visitor.php'); } } // we'll `try` to scan the license if the checkbox is selected if (isset($_POST['pic_id'])) { // get the info from the db $query = 'select id from visitors where license_no = "'.$license_no.'"'; $result = mysqli_query($con, $query); while ($row = mysqli_fetch_array($result)) { $id = $row['id']; // set up the path to save the id to (and put path into db for further look up // and display) $dir = ( $id % 30 ); $path = '/var/www/olin/images/licenses/'.$dir.'/'.$id.'-license.png'; $path = addslashes(mysqli_real_escape_string($con, $path)); $path1 = '/images/licenses/'.$dir.'/'.$id.'-license.png'; // start the scan, and save image $command = '/home/jmd9qs/bin/scan.sh "'.$path.'"'; $update = 'update visitors set id_pic = "'.$path1.'" where id="'.$id.'"'; mysqli_query($con, $update) or die ('Error: ' . mysqli_error($con)); exec($command); header('Location: http://localhost/olin/visitor.php'); } } ?&gt; </code></pre> <p>Can anybody provide any hints?</p> <p>UPDATE:</p> <p>I have the server running the command now (I know it's failing because of the Apache2 error log).</p> <p>Here's the error I get: <code>scanimage: open of device brother3:bus2;dev1 failed: Invalid argument</code></p> <p>I've tried adding the www-data user to the <code>scanner</code> and <code>lp</code> groups, but it seems to have no effect... The <code>scanimage</code> command I'm using works under my normal user and as root, so I'm now positive the command I'm using should work. I am still at a loss...</p> <p>UPDATE (again):</p> <p>I've fixed some errors in my code... now the server <em>will</em> scan and successfully save images! However, it only works once and then for some odd reason I have to run the <code>scan.sh</code> (which I put the <code>scanimage</code> command into) through my shell for it to run again... otherwise I get the same error message!</p> <p>Very weird, I have NO clue why, suggestions wanted!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload