Hi!
I'm trying to write a script in which a message is displayed by xmessage if X is running otherwise message is displayed by echo
I tried this :
if [ -f /tmp/.X0-lock ] then xmessage message
else echo message
However lets suppose that I'm running X and working on a Virtual Console. the file /tmp/.X0-lock would then exist. How do I now display the message using echo ?
Please guide
P.S. I'm using FreeBSD (It's kinda cool ;)). I guess the working of X is same under all Unices.
On Wed, 5 Feb 2003, Nikhil Joshi wrote:
I'm trying to write a script in which a message is displayed by xmessage if X is running otherwise message is displayed by echo
I tried this :
if [ -f /tmp/.X0-lock ] then xmessage message
else echo message
However lets suppose that I'm running X and working on a Virtual Console. the file /tmp/.X0-lock would then exist. How do I now display the message using echo ?
try this:
# If X not running --> use echo --> else use xmessage [ x"$DISPLAY" == "x" ] && ECHOBIN=echo || ECHOBIN=`which xmessage` #... your rest of the script # tell something to user $ECHOBIN "Welcome to wonderful world of scripting!"
HTH,
Rajesh
On Wed, 5 Feb 2003, Nikhil Joshi wrote:
I'm trying to write a script in which a message is displayed by xmessage if X is running otherwise message is displayed by echo
I tried this :
if [ -f /tmp/.X0-lock ]
to test for the availability of X, look for the environment variable called DISPLAY:
if [ -n "$DISPLAY" ]; then xmessage message else echo message fi