PHP to access shell script to print barcodes

PHP to access shell script to print barcodes

am 23.03.2010 04:27:22 von Rob Gould

--Boundary_(ID_+f0P1Onci1P3k9SxwBtAkA)
Content-type: text/plain; charset=utf-8
Content-transfer-encoding: quoted-printable

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â€=B3;
NR=3D$BASE

for hor in 30 220 410
do
ver=3D740
while [ $ver -ge 40 ];
do
printf -v FNR â€=9C(%06dL3)â€=9D $NR
echo â€=9C$hor $ver moveto $FNR (includetext height=3D0.55) code39 =
barcodeâ€=9D
let ver=3D$ver-70
let NR=3DNR+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.ph p

Which has the following script:


=
$command=3D"http://www.winecarepro.com/kiosk/fast/shell/barc ode_with_sampl=
e.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.



--Boundary_(ID_+f0P1Onci1P3k9SxwBtAkA)--

Re: PHP to access shell script to print barcodes

am 23.03.2010 06:48:24 von Jochem Maas

Op 3/23/10 3:27 AM, Rob Gould schreef:
> 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.ph p
>
> Which has the following script:
>
> >
> $command="http://www.winecarepro.com/kiosk/fast/shell/barcod e_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.

that's what exec() is for. $command need to contain a *local* path to the command in question, currently your
trying to pass a url to bash ... which obviously doesn't do much.

the shell script in question needs to have the executable bit set in order to run (either that or change to command to
run bash with your script as an argument)

I'd also suggest putting the shell script outside of your webroot, or at least in a directory that's not accessable
from the web.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP to access shell script to print barcodes

am 23.03.2010 12:48:26 von Richard Quadling

On 23 March 2010 05:48, Jochem Maas wrote:
> Op 3/23/10 3:27 AM, Rob Gould schreef:
>> 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 bar=
codes.  That's _exactly_ what I'm after.
>> Fortunately, the author gives step-by-step instructions on how to do thi=
s 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â€=B3;
>> NR=3D$BASE
>>
>> for hor in 30 220 410
>> do
>> ver=3D740
>> while [ $ver -ge 40 ];
>> do
>> printf -v FNR â€=9C(%06dL3)â€=9D $NR
>> echo â€=9C$hor $ver moveto $FNR (includetext height=3D0.55) code39 b=
arcodeâ€=9D
>> let ver=3D$ver-70
>> let NR=3DNR+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.ph p
>>
>> Which has the following script:
>>
>> >>
>> $command=3D"http://www.winecarepro.com/kiosk/fast/shell/barc ode_with_sam=
ple.ps";
>> exec($command, $arr);
>>
>> echo $arr;
>>
>> ?>
>>
>>
>> And, as you can see, nothing works.  I guess firstly, I'd like to k=
now:
>>
>> 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 n=
ot really executing.
>
> that's what exec() is for. $command need to contain a *local* path to the=
command in question, currently your
> trying to pass a url to bash ... which obviously doesn't do much.
>
> the shell script in question needs to have the executable bit set in orde=
r to run (either that or change to command to
> run bash with your script as an argument)
>
> I'd also suggest putting the shell script outside of your webroot, or at =
least in a directory that's not accessable
> from the web.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I think this is a translation of the script to PHP.

$BASE =3D 100;
$NR =3D $BASE;

foreach(array(30, 220, 410) as $hor) {
$ver =3D 740;
while ($ver >=3D 40) {
printf("$hor $ver moveto (%06dL3) (includetext height=3D0.55) code39
barcode\n", $NR);
$ver -=3D 70;
++$NR;
}
}



It produces output like ...

30 740 moveto (000100L3) (includetext height=3D0.55) code39 barcode
30 670 moveto (000101L3) (includetext height=3D0.55) code39 barcode
30 600 moveto (000102L3) (includetext height=3D0.55) code39 barcode
30 530 moveto (000103L3) (includetext height=3D0.55) code39 barcode
30 460 moveto (000104L3) (includetext height=3D0.55) code39 barcode
30 390 moveto (000105L3) (includetext height=3D0.55) code39 barcode
30 320 moveto (000106L3) (includetext height=3D0.55) code39 barcode
30 250 moveto (000107L3) (includetext height=3D0.55) code39 barcode
30 180 moveto (000108L3) (includetext height=3D0.55) code39 barcode
30 110 moveto (000109L3) (includetext height=3D0.55) code39 barcode
30 40 moveto (000110L3) (includetext height=3D0.55) code39 barcode
220 740 moveto (000111L3) (includetext height=3D0.55) code39 barcode
220 670 moveto (000112L3) (includetext height=3D0.55) code39 barcode
220 600 moveto (000113L3) (includetext height=3D0.55) code39 barcode
220 530 moveto (000114L3) (includetext height=3D0.55) code39 barcode
220 460 moveto (000115L3) (includetext height=3D0.55) code39 barcode
220 390 moveto (000116L3) (includetext height=3D0.55) code39 barcode
220 320 moveto (000117L3) (includetext height=3D0.55) code39 barcode
220 250 moveto (000118L3) (includetext height=3D0.55) code39 barcode
220 180 moveto (000119L3) (includetext height=3D0.55) code39 barcode
220 110 moveto (000120L3) (includetext height=3D0.55) code39 barcode
220 40 moveto (000121L3) (includetext height=3D0.55) code39 barcode
410 740 moveto (000122L3) (includetext height=3D0.55) code39 barcode
410 670 moveto (000123L3) (includetext height=3D0.55) code39 barcode
410 600 moveto (000124L3) (includetext height=3D0.55) code39 barcode
410 530 moveto (000125L3) (includetext height=3D0.55) code39 barcode
410 460 moveto (000126L3) (includetext height=3D0.55) code39 barcode
410 390 moveto (000127L3) (includetext height=3D0.55) code39 barcode
410 320 moveto (000128L3) (includetext height=3D0.55) code39 barcode
410 250 moveto (000129L3) (includetext height=3D0.55) code39 barcode
410 180 moveto (000130L3) (includetext height=3D0.55) code39 barcode
410 110 moveto (000131L3) (includetext height=3D0.55) code39 barcode
410 40 moveto (000132L3) (includetext height=3D0.55) code39 barcode


No idea if that is accurate or not. If you can run the script by hand
once to confirm, then
--=20
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213474=
731
ZOPA : http://uk.zopa.com/member/RQuadling

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP to access shell script to print barcodes

am 23.03.2010 22:10:56 von Rob Gould

I love the idea of using PHP to insert data into Postscript. I'm just =
not sure how to make it happen.

The good news is that I've got barcodes drawing just the way I need =
them:

http://www.winecarepro.com/kiosk/fast/shell/barcodemerge.ps

The bad news is that's all hard-coded Postscript. I'd like to take your =
suggestion and use PHP to loop-through and draw the barcodes - - - =
however, if I put anything that resembles PHP in my .ps file, bad things =
happen.

Anyone know the secret to creating a postscript .ps file that had PHP =
code injecting data into it?

Here's the source file that works. Where PHP would be handy is at the =
very bottom of the script....

http://www.winecarepro.com/kiosk/fast/shell/barcodemerge.ps. zip


On Mar 23, 2010, at 7:48 AM, Richard Quadling wrote:

> On 23 March 2010 05:48, Jochem Maas wrote:
>> Op 3/23/10 3:27 AM, Rob Gould schreef:
>>> I am trying to replicate the functionality that I see on this site:
>>>=20
>>> http://blog.maniac.nl/webbased-pdf-lto-barcode-generator/
>>>=20
>>> 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:
>>>=20
>>> http://blog.maniac.nl/2008/05/28/creating-lto-barcodes/
>>>=20
>>>=20
>>> So I've gotten through all the steps, and have created the =
"barcode_with_samples.ps" file, and have it hosted here:
>>>=20
>>> http://www.winecarepro.com/kiosk/fast/shell/
>>>=20
>>> Notice how the last few lines contain the shell-script that renders =
the postscript:
>>>=20
>>> #!/bin/bash
>>>=20
>>> BASE=”100â€=B3;
>>> NR=3D$BASE
>>>=20
>>> for hor in 30 220 410
>>> do
>>> ver=3D740
>>> while [ $ver -ge 40 ];
>>> do
>>> printf -v FNR â€=9C(%06dL3)â€=9D $NR
>>> echo â€=9C$hor $ver moveto $FNR (includetext height=3D0.55) =
code39 barcodeâ€=9D
>>> let ver=3D$ver-70
>>> let NR=3DNR+1
>>> done
>>> done
>>>=20
>>>=20
>>> 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:
>>>=20
>>> http://www.winecarepro.com/kiosk/fast/shell/printbarcodes.ph p
>>>=20
>>> Which has the following script:
>>>=20
>>> >>>=20
>>> =
$command=3D"http://www.winecarepro.com/kiosk/fast/shell/barc ode_with_sampl=
e.ps";
>>> exec($command, $arr);
>>>=20
>>> echo $arr;
>>>=20
>>> ?>
>>>=20
>>>=20
>>> And, as you can see, nothing works. I guess firstly, I'd like to =
know:
>>>=20
>>> 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.
>>=20
>> that's what exec() is for. $command need to contain a *local* path to =
the command in question, currently your
>> trying to pass a url to bash ... which obviously doesn't do much.
>>=20
>> the shell script in question needs to have the executable bit set in =
order to run (either that or change to command to
>> run bash with your script as an argument)
>>=20
>> I'd also suggest putting the shell script outside of your webroot, or =
at least in a directory that's not accessable
>> from the web.
>>=20
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>=20
>>=20
>=20
> I think this is a translation of the script to PHP.
>=20
> > $BASE =3D 100;
> $NR =3D $BASE;
>=20
> foreach(array(30, 220, 410) as $hor) {
> $ver =3D 740;
> while ($ver >=3D 40) {
> printf("$hor $ver moveto (%06dL3) (includetext =
height=3D0.55) code39
> barcode\n", $NR);
> $ver -=3D 70;
> ++$NR;
> }
> }
>=20
>=20
>=20
> It produces output like ...
>=20
> 30 740 moveto (000100L3) (includetext height=3D0.55) code39 barcode
> 30 670 moveto (000101L3) (includetext height=3D0.55) code39 barcode
> 30 600 moveto (000102L3) (includetext height=3D0.55) code39 barcode
> 30 530 moveto (000103L3) (includetext height=3D0.55) code39 barcode
> 30 460 moveto (000104L3) (includetext height=3D0.55) code39 barcode
> 30 390 moveto (000105L3) (includetext height=3D0.55) code39 barcode
> 30 320 moveto (000106L3) (includetext height=3D0.55) code39 barcode
> 30 250 moveto (000107L3) (includetext height=3D0.55) code39 barcode
> 30 180 moveto (000108L3) (includetext height=3D0.55) code39 barcode
> 30 110 moveto (000109L3) (includetext height=3D0.55) code39 barcode
> 30 40 moveto (000110L3) (includetext height=3D0.55) code39 barcode
> 220 740 moveto (000111L3) (includetext height=3D0.55) code39 barcode
> 220 670 moveto (000112L3) (includetext height=3D0.55) code39 barcode
> 220 600 moveto (000113L3) (includetext height=3D0.55) code39 barcode
> 220 530 moveto (000114L3) (includetext height=3D0.55) code39 barcode
> 220 460 moveto (000115L3) (includetext height=3D0.55) code39 barcode
> 220 390 moveto (000116L3) (includetext height=3D0.55) code39 barcode
> 220 320 moveto (000117L3) (includetext height=3D0.55) code39 barcode
> 220 250 moveto (000118L3) (includetext height=3D0.55) code39 barcode
> 220 180 moveto (000119L3) (includetext height=3D0.55) code39 barcode
> 220 110 moveto (000120L3) (includetext height=3D0.55) code39 barcode
> 220 40 moveto (000121L3) (includetext height=3D0.55) code39 barcode
> 410 740 moveto (000122L3) (includetext height=3D0.55) code39 barcode
> 410 670 moveto (000123L3) (includetext height=3D0.55) code39 barcode
> 410 600 moveto (000124L3) (includetext height=3D0.55) code39 barcode
> 410 530 moveto (000125L3) (includetext height=3D0.55) code39 barcode
> 410 460 moveto (000126L3) (includetext height=3D0.55) code39 barcode
> 410 390 moveto (000127L3) (includetext height=3D0.55) code39 barcode
> 410 320 moveto (000128L3) (includetext height=3D0.55) code39 barcode
> 410 250 moveto (000129L3) (includetext height=3D0.55) code39 barcode
> 410 180 moveto (000130L3) (includetext height=3D0.55) code39 barcode
> 410 110 moveto (000131L3) (includetext height=3D0.55) code39 barcode
> 410 40 moveto (000132L3) (includetext height=3D0.55) code39 barcode
>=20
>=20
> No idea if that is accurate or not. If you can run the script by hand
> once to confirm, then
> --=20
> -----
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
> Zend Certified Engineer : =
http://zend.com/zce.php?c=3DZEND002498&r=3D213474731
> ZOPA : http://uk.zopa.com/member/RQuadling


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP to access shell script to print barcodes

am 23.03.2010 22:37:29 von Peter Lind

You can create a .php script that sets a proper header to make the
browser download the file rather than display it. That also allows you
to set the filename for the download. What you'd need to do is include
something like:

header("Content-Disposition: attachment; filename: 'barcodemerge.ps'");

That tells the browser to download the file. You can also try setting
the content-type

header('Content-type: application/postscript');

Either of the above might do the trick for you.

Regards
Peter

On 23 March 2010 22:10, Rob Gould wrote:
> I love the idea of using PHP to insert data into Postscript.  I'm ju=
st not sure how to make it happen.
>
> The good news is that I've got barcodes drawing just the way I need them:
>
> http://www.winecarepro.com/kiosk/fast/shell/barcodemerge.ps
>
> The bad news is that's all hard-coded Postscript.  I'd like to take =
your suggestion and use PHP to loop-through and draw the barcodes - - - how=
ever, if I put anything that resembles PHP in my .ps file, bad things happe=
n.
>
> Anyone know the secret to creating a postscript .ps file that had PHP cod=
e injecting data into it?
>
> Here's the source file that works.  Where PHP would be handy is at t=
he very bottom of the script....
>
> http://www.winecarepro.com/kiosk/fast/shell/barcodemerge.ps. zip
>
>
> On Mar 23, 2010, at 7:48 AM, Richard Quadling wrote:
>
>> On 23 March 2010 05:48, Jochem Maas wrote:
>>> Op 3/23/10 3:27 AM, Rob Gould schreef:
>>>> 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 b=
arcodes.  That's _exactly_ what I'm after.
>>>> Fortunately, the author gives step-by-step instructions on how to do t=
his 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_wi=
th_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 th=
e postscript:
>>>>
>>>> #!/bin/bash
>>>>
>>>> BASE=”100â€=B3;
>>>> NR=3D$BASE
>>>>
>>>> for hor in 30 220 410
>>>> do
>>>> ver=3D740
>>>> while [ $ver -ge 40 ];
>>>> do
>>>> printf -v FNR â€=9C(%06dL3)â€=9D $NR
>>>> echo â€=9C$hor $ver moveto $FNR (includetext height=3D0.55) code39=
barcodeâ€=9D
>>>> let ver=3D$ver-70
>>>> let NR=3DNR+1
>>>> done
>>>> done
>>>>
>>>>
>>>> I need to somehow create a PHP script that "executes" this shell scrip=
t.  And after doing some research, it sounds like
>>>> I need to use the PHP exec command, so I do that with the following fi=
le:
>>>>
>>>> http://www.winecarepro.com/kiosk/fast/shell/printbarcodes.ph p
>>>>
>>>> Which has the following script:
>>>>
>>>> >>>>
>>>> $command=3D"http://www.winecarepro.com/kiosk/fast/shell/barc ode_with_s=
ample.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 thi=
s shell script?  Is there a better way?  It seems to me like it's=
not really executing.
>>>
>>> that's what exec() is for. $command need to contain a *local* path to t=
he command in question, currently your
>>> trying to pass a url to bash ... which obviously doesn't do much.
>>>
>>> the shell script in question needs to have the executable bit set in or=
der to run (either that or change to command to
>>> run bash with your script as an argument)
>>>
>>> I'd also suggest putting the shell script outside of your webroot, or a=
t least in a directory that's not accessable
>>> from the web.
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> I think this is a translation of the script to PHP.
>>
>> >> $BASE =3D 100;
>> $NR   =3D $BASE;
>>
>> foreach(array(30, 220, 410) as $hor) {
>>       $ver =3D 740;
>>       while ($ver >=3D 40) {
>>               printf("$hor $ver movet=
o (%06dL3) (includetext height=3D0.55) code39
>> barcode\n", $NR);
>>               $ver -=3D 70;
>>               ++$NR;
>>       }
>> }
>>
>>
>>
>> It produces output like ...
>>
>> 30 740 moveto (000100L3) (includetext height=3D0.55) code39 barcode
>> 30 670 moveto (000101L3) (includetext height=3D0.55) code39 barcode
>> 30 600 moveto (000102L3) (includetext height=3D0.55) code39 barcode
>> 30 530 moveto (000103L3) (includetext height=3D0.55) code39 barcode
>> 30 460 moveto (000104L3) (includetext height=3D0.55) code39 barcode
>> 30 390 moveto (000105L3) (includetext height=3D0.55) code39 barcode
>> 30 320 moveto (000106L3) (includetext height=3D0.55) code39 barcode
>> 30 250 moveto (000107L3) (includetext height=3D0.55) code39 barcode
>> 30 180 moveto (000108L3) (includetext height=3D0.55) code39 barcode
>> 30 110 moveto (000109L3) (includetext height=3D0.55) code39 barcode
>> 30 40 moveto (000110L3) (includetext height=3D0.55) code39 barcode
>> 220 740 moveto (000111L3) (includetext height=3D0.55) code39 barcode
>> 220 670 moveto (000112L3) (includetext height=3D0.55) code39 barcode
>> 220 600 moveto (000113L3) (includetext height=3D0.55) code39 barcode
>> 220 530 moveto (000114L3) (includetext height=3D0.55) code39 barcode
>> 220 460 moveto (000115L3) (includetext height=3D0.55) code39 barcode
>> 220 390 moveto (000116L3) (includetext height=3D0.55) code39 barcode
>> 220 320 moveto (000117L3) (includetext height=3D0.55) code39 barcode
>> 220 250 moveto (000118L3) (includetext height=3D0.55) code39 barcode
>> 220 180 moveto (000119L3) (includetext height=3D0.55) code39 barcode
>> 220 110 moveto (000120L3) (includetext height=3D0.55) code39 barcode
>> 220 40 moveto (000121L3) (includetext height=3D0.55) code39 barcode
>> 410 740 moveto (000122L3) (includetext height=3D0.55) code39 barcode
>> 410 670 moveto (000123L3) (includetext height=3D0.55) code39 barcode
>> 410 600 moveto (000124L3) (includetext height=3D0.55) code39 barcode
>> 410 530 moveto (000125L3) (includetext height=3D0.55) code39 barcode
>> 410 460 moveto (000126L3) (includetext height=3D0.55) code39 barcode
>> 410 390 moveto (000127L3) (includetext height=3D0.55) code39 barcode
>> 410 320 moveto (000128L3) (includetext height=3D0.55) code39 barcode
>> 410 250 moveto (000129L3) (includetext height=3D0.55) code39 barcode
>> 410 180 moveto (000130L3) (includetext height=3D0.55) code39 barcode
>> 410 110 moveto (000131L3) (includetext height=3D0.55) code39 barcode
>> 410 40 moveto (000132L3) (includetext height=3D0.55) code39 barcode
>>
>>
>> No idea if that is accurate or not. If you can run the script by hand
>> once to confirm, then
>> --
>> -----
>> Richard Quadling
>> "Standing on the shoulders of some very clever giants!"
>> EE : http://www.experts-exchange.com/M_248814.html
>> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
>> Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D213=
474731
>> ZOPA : http://uk.zopa.com/member/RQuadling
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



--=20

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP to access shell script to print barcodes

am 24.03.2010 06:09:05 von Rob Gould

Well, that did something, and it does sound like it should work. I've =
scoured the web and haven't found anyone with code that does what I'm =
trying to do.

I've got a working, hardcoded Postscript file here:

http://www.winecarepro.com/kiosk/fast/shell/barcodemerge.ps

But I need to somehow serve it with PHP, so I can change some variables =
in it. =20

By putting headers in place with PHP, and then doing an "echo" of the =
postscript, I get postscript errors (though Preview doesn't tell me what =
the error is):

http://www.winecarepro.com/kiosk/fast/shell/serverps.ps

Trying to trick the web-browser into thinking it's receiving Postscript =
from a PHP file is tricky. I don't know what to do next.

Here's the code I was using in the above url: =
http://www.winecarepro.com/kiosk/fast/shell/serveps.php.zip

It's not clear to me if the server is parsing the postscript first and =
then serving it, or if the server is server the postscript as-is and the =
browser sends it to Preview which interprets it.

I basically want to replicate the functionality found here:

http://blog.maniac.nl/webbased-pdf-lto-barcode-generator/



On Mar 23, 2010, at 5:37 PM, Peter Lind wrote:

> You can create a .php script that sets a proper header to make the
> browser download the file rather than display it. That also allows you
> to set the filename for the download. What you'd need to do is include
> something like:
>=20
> header("Content-Disposition: attachment; filename: =
'barcodemerge.ps'");
>=20
> That tells the browser to download the file. You can also try setting
> the content-type
>=20
> header('Content-type: application/postscript');
>=20
> Either of the above might do the trick for you.
>=20
> Regards
> Peter
>=20
> On 23 March 2010 22:10, Rob Gould wrote:
>> I love the idea of using PHP to insert data into Postscript. I'm =
just not sure how to make it happen.
>>=20
>> The good news is that I've got barcodes drawing just the way I need =
them:
>>=20
>> http://www.winecarepro.com/kiosk/fast/shell/barcodemerge.ps
>>=20
>> The bad news is that's all hard-coded Postscript. I'd like to take =
your suggestion and use PHP to loop-through and draw the barcodes - - - =
however, if I put anything that resembles PHP in my .ps file, bad things =
happen.
>>=20
>> Anyone know the secret to creating a postscript .ps file that had PHP =
code injecting data into it?
>>=20
>> Here's the source file that works. Where PHP would be handy is at =
the very bottom of the script....
>>=20
>> http://www.winecarepro.com/kiosk/fast/shell/barcodemerge.ps. zip
>>=20
>>=20
>> On Mar 23, 2010, at 7:48 AM, Richard Quadling wrote:
>>=20
>>> On 23 March 2010 05:48, Jochem Maas wrote:
>>>> Op 3/23/10 3:27 AM, Rob Gould schreef:
>>>>> I am trying to replicate the functionality that I see on this =
site:
>>>>>=20
>>>>> http://blog.maniac.nl/webbased-pdf-lto-barcode-generator/
>>>>>=20
>>>>> 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:
>>>>>=20
>>>>> http://blog.maniac.nl/2008/05/28/creating-lto-barcodes/
>>>>>=20
>>>>>=20
>>>>> So I've gotten through all the steps, and have created the =
"barcode_with_samples.ps" file, and have it hosted here:
>>>>>=20
>>>>> http://www.winecarepro.com/kiosk/fast/shell/
>>>>>=20
>>>>> Notice how the last few lines contain the shell-script that =
renders the postscript:
>>>>>=20
>>>>> #!/bin/bash
>>>>>=20
>>>>> BASE=”100â€=B3;
>>>>> NR=3D$BASE
>>>>>=20
>>>>> for hor in 30 220 410
>>>>> do
>>>>> ver=3D740
>>>>> while [ $ver -ge 40 ];
>>>>> do
>>>>> printf -v FNR â€=9C(%06dL3)â€=9D $NR
>>>>> echo â€=9C$hor $ver moveto $FNR (includetext height=3D0.55) =
code39 barcodeâ€=9D
>>>>> let ver=3D$ver-70
>>>>> let NR=3DNR+1
>>>>> done
>>>>> done
>>>>>=20
>>>>>=20
>>>>> 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:
>>>>>=20
>>>>> http://www.winecarepro.com/kiosk/fast/shell/printbarcodes.ph p
>>>>>=20
>>>>> Which has the following script:
>>>>>=20
>>>>> >>>>>=20
>>>>> =
$command=3D"http://www.winecarepro.com/kiosk/fast/shell/barc ode_with_sampl=
e.ps";
>>>>> exec($command, $arr);
>>>>>=20
>>>>> echo $arr;
>>>>>=20
>>>>> ?>
>>>>>=20
>>>>>=20
>>>>> And, as you can see, nothing works. I guess firstly, I'd like to =
know:
>>>>>=20
>>>>> 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.
>>>>=20
>>>> that's what exec() is for. $command need to contain a *local* path =
to the command in question, currently your
>>>> trying to pass a url to bash ... which obviously doesn't do much.
>>>>=20
>>>> the shell script in question needs to have the executable bit set =
in order to run (either that or change to command to
>>>> run bash with your script as an argument)
>>>>=20
>>>> I'd also suggest putting the shell script outside of your webroot, =
or at least in a directory that's not accessable
>>>> from the web.
>>>>=20
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>=20
>>>>=20
>>>=20
>>> I think this is a translation of the script to PHP.
>>>=20
>>> >>> $BASE =3D 100;
>>> $NR =3D $BASE;
>>>=20
>>> foreach(array(30, 220, 410) as $hor) {
>>> $ver =3D 740;
>>> while ($ver >=3D 40) {
>>> printf("$hor $ver moveto (%06dL3) (includetext =
height=3D0.55) code39
>>> barcode\n", $NR);
>>> $ver -=3D 70;
>>> ++$NR;
>>> }
>>> }
>>>=20
>>>=20
>>>=20
>>> It produces output like ...
>>>=20
>>> 30 740 moveto (000100L3) (includetext height=3D0.55) code39 barcode
>>> 30 670 moveto (000101L3) (includetext height=3D0.55) code39 barcode
>>> 30 600 moveto (000102L3) (includetext height=3D0.55) code39 barcode
>>> 30 530 moveto (000103L3) (includetext height=3D0.55) code39 barcode
>>> 30 460 moveto (000104L3) (includetext height=3D0.55) code39 barcode
>>> 30 390 moveto (000105L3) (includetext height=3D0.55) code39 barcode
>>> 30 320 moveto (000106L3) (includetext height=3D0.55) code39 barcode
>>> 30 250 moveto (000107L3) (includetext height=3D0.55) code39 barcode
>>> 30 180 moveto (000108L3) (includetext height=3D0.55) code39 barcode
>>> 30 110 moveto (000109L3) (includetext height=3D0.55) code39 barcode
>>> 30 40 moveto (000110L3) (includetext height=3D0.55) code39 barcode
>>> 220 740 moveto (000111L3) (includetext height=3D0.55) code39 barcode
>>> 220 670 moveto (000112L3) (includetext height=3D0.55) code39 barcode
>>> 220 600 moveto (000113L3) (includetext height=3D0.55) code39 barcode
>>> 220 530 moveto (000114L3) (includetext height=3D0.55) code39 barcode
>>> 220 460 moveto (000115L3) (includetext height=3D0.55) code39 barcode
>>> 220 390 moveto (000116L3) (includetext height=3D0.55) code39 barcode
>>> 220 320 moveto (000117L3) (includetext height=3D0.55) code39 barcode
>>> 220 250 moveto (000118L3) (includetext height=3D0.55) code39 barcode
>>> 220 180 moveto (000119L3) (includetext height=3D0.55) code39 barcode
>>> 220 110 moveto (000120L3) (includetext height=3D0.55) code39 barcode
>>> 220 40 moveto (000121L3) (includetext height=3D0.55) code39 barcode
>>> 410 740 moveto (000122L3) (includetext height=3D0.55) code39 barcode
>>> 410 670 moveto (000123L3) (includetext height=3D0.55) code39 barcode
>>> 410 600 moveto (000124L3) (includetext height=3D0.55) code39 barcode
>>> 410 530 moveto (000125L3) (includetext height=3D0.55) code39 barcode
>>> 410 460 moveto (000126L3) (includetext height=3D0.55) code39 barcode
>>> 410 390 moveto (000127L3) (includetext height=3D0.55) code39 barcode
>>> 410 320 moveto (000128L3) (includetext height=3D0.55) code39 barcode
>>> 410 250 moveto (000129L3) (includetext height=3D0.55) code39 barcode
>>> 410 180 moveto (000130L3) (includetext height=3D0.55) code39 barcode
>>> 410 110 moveto (000131L3) (includetext height=3D0.55) code39 barcode
>>> 410 40 moveto (000132L3) (includetext height=3D0.55) code39 barcode
>>>=20
>>>=20
>>> No idea if that is accurate or not. If you can run the script by =
hand
>>> once to confirm, then
>>> --
>>> -----
>>> Richard Quadling
>>> "Standing on the shoulders of some very clever giants!"
>>> EE : http://www.experts-exchange.com/M_248814.html
>>> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
>>> Zend Certified Engineer : =
http://zend.com/zce.php?c=3DZEND002498&r=3D213474731
>>> ZOPA : http://uk.zopa.com/member/RQuadling
>>=20
>>=20
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>=20
>>=20
>=20
>=20
>=20
> --=20
>
> WWW: http://plphp.dk / http://plind.dk
> LinkedIn: http://www.linkedin.com/in/plind
> Flickr: http://www.flickr.com/photos/fake51
> BeWelcome: Fake51
> Couchsurfing: Fake51
>



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP to access shell script to print barcodes

am 24.03.2010 08:35:54 von Peter Lind

The problem you're getting is that your web-server interprets the
request as a request for a normal file and just sends it - in effect,
you're not outputting the postscript file, you're just sending the
..php file. Normally, you'll only get your php executed if the file
requested is a .php or .phtml - unless you've changed your server
config.

Try creating a serveps.php that uses the header("Content-Disposition:
attachment; filename: 'serveps.ps'") instead, see if that helps you.

Regards

On 24 March 2010 06:09, Rob Gould wrote:
> Well, that did something, and it does sound like it should work.  I'=
ve scoured the web and haven't found anyone with code that does what I'm tr=
ying to do.
>
> I've got a working, hardcoded Postscript file here:
>
> http://www.winecarepro.com/kiosk/fast/shell/barcodemerge.ps
>
> But I need to somehow serve it with PHP, so I can change some variables i=
n it.
>
> By putting headers in place with PHP, and then doing an "echo" of the pos=
tscript, I get postscript errors (though Preview doesn't tell me what the e=
rror is):
>
> http://www.winecarepro.com/kiosk/fast/shell/serverps.ps
>
> Trying to trick the web-browser into thinking it's receiving Postscript f=
rom a PHP file is tricky.  I don't know what to do next.
>
> Here's the code I was using in the above url:  http://www.winecarepr=
o.com/kiosk/fast/shell/serveps.php.zip
>
> It's not clear to me if the server is parsing the postscript first and th=
en serving it, or if the server is server the postscript as-is and the brow=
ser sends it to Preview which interprets it.
>
> I basically want to replicate the functionality found here:
>
> http://blog.maniac.nl/webbased-pdf-lto-barcode-generator/
>
>
>
> On Mar 23, 2010, at 5:37 PM, Peter Lind wrote:
>
>> You can create a .php script that sets a proper header to make the
>> browser download the file rather than display it. That also allows you
>> to set the filename for the download. What you'd need to do is include
>> something like:
>>
>> header("Content-Disposition: attachment; filename: 'barcodemerge.ps'");
>>
>> That tells the browser to download the file. You can also try setting
>> the content-type
>>
>> header('Content-type: application/postscript');
>>
>> Either of the above might do the trick for you.
>>
>> Regards
>> Peter
>>
>> On 23 March 2010 22:10, Rob Gould wrote:
>>> I love the idea of using PHP to insert data into Postscript.  I'm =
just not sure how to make it happen.
>>>
>>> The good news is that I've got barcodes drawing just the way I need the=
m:
>>>
>>> http://www.winecarepro.com/kiosk/fast/shell/barcodemerge.ps
>>>
>>> The bad news is that's all hard-coded Postscript.  I'd like to tak=
e your suggestion and use PHP to loop-through and draw the barcodes - - - h=
owever, if I put anything that resembles PHP in my .ps file, bad things hap=
pen.
>>>
>>> Anyone know the secret to creating a postscript .ps file that had PHP c=
ode injecting data into it?
>>>
>>> Here's the source file that works.  Where PHP would be handy is at=
the very bottom of the script....
>>>
>>> http://www.winecarepro.com/kiosk/fast/shell/barcodemerge.ps. zip
>>>
>>>
>>> On Mar 23, 2010, at 7:48 AM, Richard Quadling wrote:
>>>
>>>> On 23 March 2010 05:48, Jochem Maas wrote:
>>>>> Op 3/23/10 3:27 AM, Rob Gould schreef:
>>>>>> 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â€=B3;
>>>>>> NR=3D$BASE
>>>>>>
>>>>>> for hor in 30 220 410
>>>>>> do
>>>>>> ver=3D740
>>>>>> while [ $ver -ge 40 ];
>>>>>> do
>>>>>> printf -v FNR â€=9C(%06dL3)â€=9D $NR
>>>>>> echo â€=9C$hor $ver moveto $FNR (includetext height=3D0.55) code=
39 barcodeâ€=9D
>>>>>> let ver=3D$ver-70
>>>>>> let NR=3DNR+1
>>>>>> done
>>>>>> done
>>>>>>
>>>>>>
>>>>>> I need to somehow create a PHP script that "executes" this shell scr=
ipt.  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.ph p
>>>>>>
>>>>>> Which has the following script:
>>>>>>
>>>>>> >>>>>>
>>>>>> $command=3D"http://www.winecarepro.com/kiosk/fast/shell/barc ode_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 t=
his shell script?  Is there a better way?  It seems to me like it=
's not really executing.
>>>>>
>>>>> that's what exec() is for. $command need to contain a *local* path to=
the command in question, currently your
>>>>> trying to pass a url to bash ... which obviously doesn't do much.
>>>>>
>>>>> the shell script in question needs to have the executable bit set in =
order to run (either that or change to command to
>>>>> run bash with your script as an argument)
>>>>>
>>>>> I'd also suggest putting the shell script outside of your webroot, or=
at least in a directory that's not accessable
>>>>> from the web.
>>>>>
>>>>> --
>>>>> PHP General Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>
>>>>>
>>>>
>>>> I think this is a translation of the script to PHP.
>>>>
>>>> >>>> $BASE =3D 100;
>>>> $NR   =3D $BASE;
>>>>
>>>> foreach(array(30, 220, 410) as $hor) {
>>>>       $ver =3D 740;
>>>>       while ($ver >=3D 40) {
>>>>               printf("$hor $ver mov=
eto (%06dL3) (includetext height=3D0.55) code39
>>>> barcode\n", $NR);
>>>>               $ver -=3D 70;
>>>>               ++$NR;
>>>>       }
>>>> }
>>>>
>>>>
>>>>
>>>> It produces output like ...
>>>>
>>>> 30 740 moveto (000100L3) (includetext height=3D0.55) code39 barcode
>>>> 30 670 moveto (000101L3) (includetext height=3D0.55) code39 barcode
>>>> 30 600 moveto (000102L3) (includetext height=3D0.55) code39 barcode
>>>> 30 530 moveto (000103L3) (includetext height=3D0.55) code39 barcode
>>>> 30 460 moveto (000104L3) (includetext height=3D0.55) code39 barcode
>>>> 30 390 moveto (000105L3) (includetext height=3D0.55) code39 barcode
>>>> 30 320 moveto (000106L3) (includetext height=3D0.55) code39 barcode
>>>> 30 250 moveto (000107L3) (includetext height=3D0.55) code39 barcode
>>>> 30 180 moveto (000108L3) (includetext height=3D0.55) code39 barcode
>>>> 30 110 moveto (000109L3) (includetext height=3D0.55) code39 barcode
>>>> 30 40 moveto (000110L3) (includetext height=3D0.55) code39 barcode
>>>> 220 740 moveto (000111L3) (includetext height=3D0.55) code39 barcode
>>>> 220 670 moveto (000112L3) (includetext height=3D0.55) code39 barcode
>>>> 220 600 moveto (000113L3) (includetext height=3D0.55) code39 barcode
>>>> 220 530 moveto (000114L3) (includetext height=3D0.55) code39 barcode
>>>> 220 460 moveto (000115L3) (includetext height=3D0.55) code39 barcode
>>>> 220 390 moveto (000116L3) (includetext height=3D0.55) code39 barcode
>>>> 220 320 moveto (000117L3) (includetext height=3D0.55) code39 barcode
>>>> 220 250 moveto (000118L3) (includetext height=3D0.55) code39 barcode
>>>> 220 180 moveto (000119L3) (includetext height=3D0.55) code39 barcode
>>>> 220 110 moveto (000120L3) (includetext height=3D0.55) code39 barcode
>>>> 220 40 moveto (000121L3) (includetext height=3D0.55) code39 barcode
>>>> 410 740 moveto (000122L3) (includetext height=3D0.55) code39 barcode
>>>> 410 670 moveto (000123L3) (includetext height=3D0.55) code39 barcode
>>>> 410 600 moveto (000124L3) (includetext height=3D0.55) code39 barcode
>>>> 410 530 moveto (000125L3) (includetext height=3D0.55) code39 barcode
>>>> 410 460 moveto (000126L3) (includetext height=3D0.55) code39 barcode
>>>> 410 390 moveto (000127L3) (includetext height=3D0.55) code39 barcode
>>>> 410 320 moveto (000128L3) (includetext height=3D0.55) code39 barcode
>>>> 410 250 moveto (000129L3) (includetext height=3D0.55) code39 barcode
>>>> 410 180 moveto (000130L3) (includetext height=3D0.55) code39 barcode
>>>> 410 110 moveto (000131L3) (includetext height=3D0.55) code39 barcode
>>>> 410 40 moveto (000132L3) (includetext height=3D0.55) code39 barcode
>>>>
>>>>
>>>> No idea if that is accurate or not. If you can run the script by hand
>>>> once to confirm, then
>>>> --
>>>> -----
>>>> Richard Quadling
>>>> "Standing on the shoulders of some very clever giants!"
>>>> EE : http://www.experts-exchange.com/M_248814.html
>>>> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
>>>> Zend Certified Engineer : http://zend.com/zce.php?c=3DZEND002498&r=3D2=
13474731
>>>> ZOPA : http://uk.zopa.com/member/RQuadling
>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>>
>>
>> --
>>
>> WWW: http://plphp.dk / http://plind.dk
>> LinkedIn: http://www.linkedin.com/in/plind
>> Flickr: http://www.flickr.com/photos/fake51
>> BeWelcome: Fake51
>> Couchsurfing: Fake51
>>

>
>



--=20

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php