[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Fun with CUPS and Pyla
Getting CUPS to work with Pyla is definitely an adventure. I've gotten
it to work by running a user space daemon that watches for socket output
from CUPS and pops up Pyla when you are ready to print.
There are some security issues with doing it this way, but it does work
on both Linux and OS X for me. There is an OS X issue where the fax
sending dialog sometimes pops up behind instead of in front of what you
are working on; I don't know if that is fixable or not.
>From what I've read this should also be possible with a cups backend
program, but that appeared to be much more complicated to do.
I've attached the script I'm using to do this for anyone who may be
interested.
--
Daniel E. Markle
#!/usr/bin/perl
# Daniel E. Markle <syntax@pa.net>
# 20031114 Revision 0.1
# This program starts up a daemon which will watch for a postscript file
# coming in from CUPS, then launch pyla to send it as a fax.
# Use it with the socket://localhost:5691 URL in cups.
# Issues:
# -security, make sure only localhost can see this port, it allows anyone
# who can stream data to this port to popup pyla on your desktop
# -must be ran as the user or the window may not pop up at the right
# place, if at all
# ***CONFIGURE ME HERE
# Port to listen on, use socket://localhost:<port> in cups
my $MY_PORT = 5691;
# Temporary file storage, this is a file not a folder
my $TMP_FILE_NAME = "/tmp/cupsfaxtemp";
# Path to pyla.py
my $PYLA_PATH = "/usr/local/pyla/pyla.py";
# Path to python binary
# use this one for Linux
my $PYTHON_PATH = "/usr/bin/python";
# use this one for OS X
#my $PYTHON_PATH = "/usr/bin/pythonw";
# ***END CONFIGURATION
# ----- You shouldn't need to touch anything beyond this point -----
use IO::Socket::INET;
# check to make sure we can use the temp file
open ( TMPFILE, ">", $TMP_FILE_NAME )
or die "Can not open temp file $TMP_FILE_NAME, " .
"check to make sure it is not owned by another user";
close ( TMPFILE );
if ( !(-e $PYLA_PATH) ) {
die "I do not see pyla at $PYLA_PATH";
}
my $data;
my $server = IO::Socket::INET->new (
LocalPort => $MY_PORT,
Type => SOCK_STREAM,
Reuse => 1,
Listen => 1
) or die "Could not start server process";
while ( my $job = $server->accept() ) {
open ( TMPFILE, ">", $TMP_FILE_NAME );
while ( <$job> ) {
print TMPFILE $_;
}
close ( TMPFILE );
close $job;
`cat "$TMP_FILE_NAME" | "$PYTHON_PATH" "$PYLA_PATH" -i`
}