1

I am trying to open a cash drawer from a Linux-share hosted PHP page. The cash drawer is a MMF POS connected through a POSX USB adapter (no receipt printer to trigger the drawer). I can run a batch file to trigger the cash drawer to open. I have not found a way to execute the .bat file from a PHP page (preferably a button on my page).

Batch file open.bat

Copy /b open.txt COM4

open.txt (unicode)

瀛─ഥ

I copied the open.bat and open .txt to c:\opendrawer of the computer connected to the POSX. I have tried creating a opendrawer.php page with the following code:

<?php system('cmd.exe /c C:\opendrawer\open.bat'); ?>

It did not trigger the cash drawer to open. No error message either. I also tried:

exec('start c:\opendrawer\open.bat');

I also know that from CMD the following command will open the register. Is there a way to setup a button on my PHP page to execute it.

echo ^G>COM4

Does anyone have a suggestion on how to get this cash drawer to open with a button click on a PHP page? Many thanks.

user3258571
  • 386
  • 3
  • 17
  • did you try just the full path itself? is the file executable by whichever user php uses? – I wrestled a bear once. Jan 09 '17 at 20:46
  • 1
    http://stackoverflow.com/questions/835941/how-do-you-run-a-bat-file-from-php –  Jan 09 '17 at 20:47
  • I have also tried unsuccessfully – user3258571 Jan 09 '17 at 20:49
  • Bear, do you mean: – user3258571 Jan 09 '17 at 20:49
  • 2
    @user3258571 When putting commands into a comment, enclose the command in backticks. [See the formatting help page](http://stackoverflow.com/help/formatting) for full details. Also, it would probably be more appropriate to put your "I also tried..." commends in your question, rather than a comment. Comments aren't intended for lengthy discussions. – rojo Jan 09 '17 at 20:51
  • @user3258571, you mean that the command `call C:\opendrawer\open.bat` executed from the console (`cmd.exe`) does open a drawer, but the command `php open.php` (open.php is ``) does not? – Dmitry Sokolov Jan 10 '17 at 00:45
  • Correct. It opens under cmd using c:\opendrawer\open.bat but not through the PHP script. – user3258571 Jan 10 '17 at 01:54
  • For a start http://stackoverflow.com/questions/21878079/communicate-with-cash-drawer-from-website – Jay Blanchard Jan 10 '17 at 19:27

0 Answers0