You are not logged in.
Basically, still the same pain with my print server. It is headless, so I need something to check my ink levels instead of logging in with ssh and type hp-levels every time.
I've managed to set up lighttpd with fcgi and python support, and the test script works fine.
How can I run hp-levels now from the web server? I just need a python script that launches hp-levels. (I've seen that the /usr/bin/hp-levels command is basically a python script)
Last edited by scar (2013-05-03 07:15:04)
“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson
Offline
I was thinking: direct the output to a textfile.
Can't a text file be read by a webserver?
Now, think about creating something special, like when only you log in.
Just some ideas.
PS - Sorry for not posting code, source, etc, etc. I'm pretty sure this will help.
Offline
Well, qucik and dirty, but here is it. It is saved as a bash script to the web servers root, the output is pretty ugly, but I do not really care.
BTW: I find it really sad that the CUPS web interface cannot display ink/toner levels for this printer. (HP Laserjet 1320)
#!/bin/bash
echo "Content-type: text/html"
echo ""
echo '<html>'
echo '<head>'
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'
echo '<title>HP LEVELS</title>'
echo '</head>'
echo '<body>'
echo 'Hp Printer Level: '
hp-levels -s 2 | grep approx | cut -d \ -f 3 | sed 's/)//'
echo '</body>'
echo '</html>'
exit 0
the output is something like:
Hp Printer Level: 22%
And thanks for the idea to leave python alone. Bash was really enough for this.
Last edited by scar (2013-05-03 07:08:50)
“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson
Offline