Page 1 of 1

exec does not work, but same command in DOS does.

Posted: Mon Nov 03, 2008 3:36 pm
by UrsusArctosHorrbilis
I think this has more to do with my apache configuration, but I'll start here hoping someone else has had a similar problem.
First off, I'm using wampserver on a pc. I have a script that prints labels to a printer connected to that pc. when I run the following command in DOS I successfully receive a label.
COPY label.zpl LPT1.
When I run the following script I do not receive a label.
exec("copy label.zpl LPT1", $output);
The result of $output is "0 file(s) copied".
There is an error in my apache log stating the following:
The system cannot find the file specified.
Can anyone offer some ideas as to why this would work in DOS, but not via the exec function?
Like I said, I think this is an apache config problem, but the part that puzzles me is that it worked just fine on a different computer and I don't recall having to change the apache config in order to get it to work.

Thanks in advance.

*solved* exec does not work, but same command in DOS does.

Posted: Tue Nov 04, 2008 9:47 am
by UrsusArctosHorrbilis
I was wrong about it being an apache configuration setting.
To solve my problem I had to create a network connection that was just a loopback. Go through the network configuration wizard and join the workgroup MSHOME. Then I had to share the printer. Then I had to modify my php script to refer to the printer as \\computer_name\printer_share_name
So now my script is as follows:
exec("copy label.zpl \\HPLAPTOP\ZEBRA", $output);
Alternatively I could run the DOS command
NET USE LPT1: \\[Computer Name]\Printer /PERSISTENT:YES
so that
exec("copy label.zpl LPT1", $output);
would work correctly, but it seems I would have to do that each time the computer is rebooted.