Hey! Did you see what David Pounder wrote on May 14 ?

DP> Is it possible for a shell script to be able to determine whether it
DP> has been invoked from within X (either from a shell window or a KDE
DP> link) or from a text console.

        Just test for the presence of the environment variable $DISPLAY.
If your script is callled from withing X then $DISPLAY will have a value.
You could test it like this:

        if [ $DISPLAY ]; then
                echo "We are in X"
        else
                echo "We are in Console"
        fi


Regards, Steve Youngs <[EMAIL PROTECTED]>   ICQ: 34307457
----------------------------------------------------------
|                                __                      |
|Isn't it good to know that     / /   __ ___  __ ____  __|
|There _IS_ an alternative!    / /__ / // _ \/ // /\ \/ /|
|                             /____//_//_//_/\_,_/ /_/\_\|
----------------------------------------------------------

If at first you don't succeed, port it to Windows.

Reply via email to