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