[sf-perl] determining console or xwindows mode

Joe Brenner doom at kzsu.stanford.edu
Sun Feb 28 18:58:13 PST 2010


Richard Reina <gatorreina at gmail.com> wrote:

> I have a program that must run differently in xwindows then it would on a
> linux console.  I was wondering if there's a function to determine if a
> program is running in a linux console or in xwindows so that upon execute
> it  can make the necessary accommodations?

My first thought is to just check the TERM environment variable:

  my $term = $ENV{TERM};

If that's defined as "xterm" or "dumb" or something, then you're
running in some sort of terminal window.

I'm not sure if that's the Right Way to do it, but I'm pretty sure
it would work.



More information about the SanFrancisco-pm mailing list