Re: 2 questions, can't find in the manual or archives . . .

From: Date: Tue, 16 Jan 2001 03:47:23 +0000
Subject: Re: 2 questions, can't find in the manual or archives . . .
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-34752@lists.php.net to get a copy of this message
> I'm writing a SYSV LP script in PHP so that I can have a > print-to-database (MySQL) solution. First question: Am I wasting my > time? Are there already canned solutions? (LPRng perhaps?) I think you could just exec() it... exec("/usr/bin/lp $blah", $output, $error); while (list(,$line) = each($output)){ echo $line, "<BR>\n"; } if ($error){ echo "OS Error $error. Usually path/permissions, but with a printer involved...<BR>\n"; } Or maybe I'm not reading enough into the phrase print-to-database, and you're doing something horribly more complicated than I think... > Second question: How do I go about opening file descriptors by > numeric referance? (LP calls script with file descriptors for passing back > debug and status info). You mean like this? $printer = fopen("/dev/3", "r"); I dunno what number your OS assigns to the printer, but 3 probably isn't it... There's also PHP constants for stdin, stdout, and stderr, and there just might be one for the printer, though I've never noticed it. > Third question: How do I trap a signal (SIGTERM specifically) in a > PHP script? Maybe, maybe, maybe... The socket() stuff will let you do that... http://php.net/manual/en/ref.sockets.php > Obviously, I have the latest PHP compiled as a CGI with native MySQL > support. My OS environ is Solaris 7. You may need to recompile with the socket stuff, which I think is optional.

« previous php.general (#34752) next »