Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing a file on a remote server

Status
Not open for further replies.

jahjah

Technical User
Jan 23, 2003
32
GB
Hello All
Need a solution on a PHP script I have created which produces labels to a users input specification. The script then needs to print the labels to the users depot which could be at one of 3 depots around the UK.
I know the standard unix command (lp -dprinter file) for printing it but Im not sure how to execute this from PHP, all help/advice gladly recieved.
 
Why not have a client application running on the machines at the depots that checks periodically for the presence of new label data and specifications. A PHP script invoked by the CRON daemon?

You will want to store all that in a database anyway, to make sure you can reprint if the printer's stuck or there something else wrong with the printing process.

Another way:
Get yourself NUSOAP and setup a SOAP daemon at the depot's machines. Write a simple SOAP client and send your data and method to the SOAP server. If you are concerned about security do it via https://

 
Hello DRJ478
Could I possibly rcp the file from within the PHP script to the remote server - if so any idea of a command I could use??
 
You can run any command by involing a shell. However, you need to be aware of the security implications. I suppose using the remote copy mechanism could be hardcoded in a way that no external variables need to be passed to the exec() command.

If you administer your own server you can make it pretty secure - if you are hosting it's a different story.
 
Why not just shell out the standard unix command from your first post?

Any shell command you'd like to execute just use the exec command (or any one of its aliases). The trick is you must be able to execute that command from your webserver, the client machine is pretty meaningless in this situation.

-Rob
 
Hello skiflyer/DRJ478

I have added a line to my PHP script:

exec("sh lab_print.sh $temp1 $PRINTER>/dev/null");

which calls upon the following shellscript - for some reason it wont copy the file to the remote server - any ideas where I may be going wrong???

#!/bin/sh
# parameters $1 = file to print, $2 = printer name
if [ "$2" = "myprinter" ] ; then
dep=london
else
dep=scotland
fi
rcp $1 $dep:/u/printdir/$1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top