| | |
A second bash to auto-run as non-root user
Thread Solved |
•
•
Join Date: Jul 2008
Posts: 36
Reputation:
Solved Threads: 0
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:
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:
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!
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 Scripting Syntax (Toggle Plain Text)
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 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!
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
Hey there,
Sometimes it will work if you just replace your exec call with a simple direct call, so instead of:
just do
<-- 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:
the output should be different for both connections.
Best wishes,
Mike
Sometimes it will work if you just replace your exec call with a simple direct call, so instead of:
•
•
•
•
exec $SHELL
•
•
•
•
$SHELL
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
Best wishes,
Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
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
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
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
![]() |
Other Threads in the Shell Scripting Forum
- Previous Thread: Can someone explain this conditional
- Next Thread: Shell script to select and insert values from mysql.
| Thread Tools | Search this Thread |





