You are not logged in.

#1 2011-12-16 23:33:59

scar
Member
From: Hungary
Registered: 2009-10-01
Posts: 444

[Solved] Bash command output in a html ( or php ) webpage

First of all, I have to tell I'm really a zero in web programming.

The thing is, that I want to find a way to display my HP printers toner levels on a webpage ( my print server runs an apache webserver for other purposes too ).

My idea was to get a cron job working ( which works ) that generates a file with the contents of my toner's levels, by doing something like:

#hp-levels > /srv/http/levels.txt

and then, include them in a webpage like:

<?PHP
include ("levels.txt");
?>

The thing is, that it works well, but the output is ugly, the lines are sticked one after the other instead of beginning a new line at each (well ) new line.

I've tried it with other bash command outputs too, like ifconfig, same thing.

So, how can I put some form on that text block?

Last edited by scar (2011-12-19 22:32:45)


“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson

Offline

#2 2011-12-16 23:51:38

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Solved] Bash command output in a html ( or php ) webpage

Have you tried e.g. https://aur.archlinux.org/packages.php?ID=33293 ?




Edit: I don't know a thing about php, but wrapping some text in <pre> tags does the trick for html:

pkg
PKGBUILD
src
txt2html-2.51-1-any.pkg.tar
txt2html-2.51.tar.gz

insead of

pkg PKGBUILD src txt2html-2.51-1-any.pkg.tar txt2html-2.51.tar.gz 

Last edited by karol (2011-12-17 00:10:58)

Offline

#3 2011-12-19 22:32:16

scar
Member
From: Hungary
Registered: 2009-10-01
Posts: 444

Re: [Solved] Bash command output in a html ( or php ) webpage

got it. thank you.


“The future has already arrived. It's just not evenly distributed yet.”
― William Gibson

Offline

Board footer

Powered by FluxBB