PHP to access shell script to print barcodes
| From: | Rob Gould | Date: | Tue, 23 Mar 2010 03:27:22 +0000 |
| Subject: | PHP to access shell script to print barcodes | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-303120@lists.php.net to get a copy of this message | ||
I am trying to replicate the functionality that I see on this site:
http://blog.maniac.nl/webbased-pdf-lto-barcode-generator/
Notice after you hit SUBMIT QUERY, you get a PDF file with a page of barcodes. That's
_exactly_ what I'm after.
Fortunately, the author gives step-by-step instructions on how to do this on this page:
http://blog.maniac.nl/2008/05/28/creating-lto-barcodes/
So I've gotten through all the steps, and have created the "barcode_with_samples.ps"
file, and have it hosted here:
http://www.winecarepro.com/kiosk/fast/shell/
Notice how the last few lines contain the shell-script that renders the postscript:
#!/bin/bash
BASE=”100″;
NR=$BASE
for hor in 30 220 410
do
ver=740
while [ $ver -ge 40 ];
do
printf -v FNR “(%06dL3)” $NR
echo “$hor $ver moveto $FNR (includetext height=0.55) code39 barcode”
let ver=$ver-70
let NR=NR+1
done
done
I need to somehow create a PHP script that "executes" this shell script. And after doing
some research, it sounds like
I need to use the PHP exec command, so I do that with the following file:
http://www.winecarepro.com/kiosk/fast/shell/printbarcodes.php
Which has the following script:
<?php
$command="http://www.winecarepro.com/kiosk/fast/shell/barcode_with_sample.ps";
exec($command, $arr);
echo $arr;
?>
And, as you can see, nothing works. I guess firstly, I'd like to know:
A) Is this PHP exec call really the way to go with executing this shell script? Is there a better
way? It seems to me like it's not really executing.
B) Can someone try following the 5 steps listed on the website
(http://blog.maniac.nl/2008/05/28/creating-lto-barcodes/) and tell me if you have any better luck?
It doesn't really sound all that difficult. I'm hosting this on Dreamhost, and I'm
not sure if there's some sort of permissions/shell exec feature I need to make this work.
I'm not convinced that I really have a functioning Postscript file. My Mac renders Postscript
files automatically after downloading with the Preview app, and I'm not seeing any valid data
returned.