Hi,
These days I have to install a higher version of bash under my $HOME on my office server. I hope to make the new bash automatically run both when I ssh to my server and when I boot into my office computer which loads my $HOME on the server. I don't have root access to the server, so I added into ~/.bash_profile that:

SHELL='${HOME}/bin/my_new_bash/bin/bash'                                                                                                      
exec $SHELL

The new bash starts automatically if I ssh to the server, however, if I try to login into my office computer, I will not be able to with the following error:

Your session only lasted less than 10 seconds. If you have not logged out yourself, this could mean that there is some installation problem or that you may be out of disk space. Try logging in with one of the failsafe sessions to see if you can fix this problem.

I can login successfully if the line "exec $SHELL" in .bash_profile is commented.

I was wondering if there is some way to make the new bash start automatically without the login error when login into my office computer?
Thanks!

Hey there,

Sometimes it will work if you just replace your exec call with a simple direct call, so instead of:

exec $SHELL

just do

$SHELL

<-- Since you're not exec'ing (i.e. replacing the current process with your new process, you shouldn't get the session timeout error since you'll just be running your new bash on top of the old one. The downside is you have to exit the shell twice to logout.

And, since it works for your ssh, you can ssh in and check the status of the $- variable. Note what that is and then change your profile to simply run the new shell rather than exec it and check teh value of the variable as well. This will show you what options are automatically set when you login with bash via ssh versus direct login. If they're different, you can add a simple if-conditional in your profile to determine whether to exec your new shell or just run it straight-up and suffer with the double exit ;)

Just FYI, you can expect to see this kind of output when you query the $- built-in:

echo $-
himBH

the output should be different for both connections.

Best wishes,

Mike

Hi Mike,
Removing "exec" works! Thanks a lot! Sorry for a little late, for I can come back to my office only on working days to have a try.
It seems that log out twice doesn't happen to me? I only need Ctrl+ALT+Backspace once to log out.
Regards

Hey,

Glad I could help. In the process, you taught me a cool trick. I never knew you could do that... all those years.... exiting over and over again just to get out of a terminal session. It figures ;)

Thanks, Lehe :)

, Mike

This question has already been answered. Start a new discussion instead.