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

Hi,

Just wondering, when you run a perl script from SSH - is there a way to make the text come up in a different color? I'm just trying to make it more obvious when there is a "good" message, and a "bad" one (i.e having the "good" messages in blue - and then "errors" in red)

Is this possible? I've seen it when doing stuff like rebooting mod_perl on our server ... but can't seem to find a way to do it in the script

TIA

UPDATE - never mind, just found a solution myself :)

use Term::ANSIColor; print color("red"), "Danger, Will Robinson!\n", color("reset"); print "This is just normal text.\n";


Andy

Replies are listed 'Best First'.
Re: Show SSH output in different colors?
by kcott (Archbishop) on Nov 15, 2010 at 20:28 UTC

    I would recommend you give serious consideration to providing a contrasting background colour with every foreground colour change. This is because a colour change that appears to stand out on a normally light background may prove difficult to read on a dark background and vice versa.

    It's also very easy to do. For instance, your example above could be changed to:

    print color("red on_yellow"), "Danger, Will Robinson!\n",

    -- Ken