rastoboy has asked for the wisdom of the Perl Monks concerning the following question:

Yo, Bro's!

I use Template Toolkit all the time to create fancy HTML/CSS/JS output while keeping my code nice and clean. But now I've been tasked with creating a little system analysis script for our techs to log into servers, run, and get a quick readout on a bunch of system stats via ssh/bash commandline.

We don't want to waste a lot of time when logging into a new server, wgetting multiple files and having to install modules and such, so I'd like to keep this as "base perl" as possible. But at the same time I'd like to present a nice, clean, formatted output, preferably color coded in nice ASCII boxes and such.

Any tips for common modules or techniques I could utilize to do this? I just hate the idea of putting formatting info into the main body of my code, because I like to enjoy maintaining it :-)

Replies are listed 'Best First'.
Re: Tips on fixed-width output formatting?
by jethro (Monsignor) on Jul 21, 2010 at 10:49 UTC

    1) How about only installing TT (Template Toolkit) in the clients (i.e. just the PCs of your techs)? If that would be ok, you would have a script on the server that just collects and sends the data and a script on the client that formats that with TT

    2) Or put up a little web server on your machine and let the techs look at that (with basic authentication). Your script would get the data the same way as above but TT would only be installed on your machine

    3) Text::Template seems to be without dependancies (you can find out these things simply through searching for 'template' in CPAN and a few more clicks, by the way). You could (instead of installing it), simply include the source of Text::Template into your script. Your script would be a little larger than intended but still in one piece and working on vanilla perl

      Good ideas, thanks!
Re: Tips on fixed-width output formatting?
by metaperl (Curate) on Jul 22, 2010 at 13:46 UTC