[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Starting X From .bash_profile



	I recently switched to bash.  I like to have X start upon login
if I'm on the console, then have the initial shell exit.  When I used
tcsh as my login shell, I used this in my .login:

# Start the X server if on the console.
set delay = 3
if (`tty` == /dev/tty1) then
    echo "Starting X11 in $delay seconds..."
    sleep $delay && (ssh-agent startx >&! /tmp/X11.out-$USER) &
    logout
endif


	And all was well.  But I can't seem to background the same
thing in bash.  I don't have a .bash_login, this is in my .bash_profile:

# Start the X server if on the console.
delay=3
if [ $(tty) = /dev/tty1 ]; then
    echo "Starting X11 in $delay seconds..."
    if sleep $delay; then
	ssh-agent startx >/tmp/X11.out-$USER 2>&1 &
	logout
    fi
fi

	But I get the error:

    X: you are not authorised to run the X server

	If I don't background the command, it works.  But I'd like to
logout from tty1, so as not to have a shell sitting there for anyone to
use by switching to that virtual console while X is running.  If I run
the same command from the console, it works fine, in the foreground
or in the background.

	I've tried all kinds of variations, with subshells, nohup,
without ssh-agent, etc., to no avail.  What's different about bash in
this regard.  Any suggestions?  Thanks...

-- 
Tres Hofmeister <tres@rap.ucar.edu>  http://www.rap.ucar.edu/staff/tres/
Research Applications Program   National Center for Atmospheric Research


Reply to: