lehe wrote:
> As to changing to new bash from the beginning, I added into .bash_profile:
> "SHELL='/cis/home/tingli/bin/bash-3.2.48/bin/bin/bash'
> exec $SHELL "
> It works quite well. The new bash starts automatically if I ssh to the
> server from my laptop.

Good.  Is there really two "/bin/bin/"s adjacent there?

> However, if I login using my office computer, which loads my HOME on server
> directly as its hard disk, 
> I will get such error:
> "Your session only lasted less than 10 seconds. ...
> If I comment the lines added to .bash_profile, I would be able to login
> successfully.

It does this because the path you supplied in your .bash_profile for
SHELL doesn't exist on that host.  Right?  On one host your home is in
one path and in another it is a different path?

> Looks like I can get only one work, either my office computer or my laptop. 

Or you need to have your .bash_profile select the appropriate path for
SHELL.  If your home is the only difference then you should use $HOME
to dynamically select the right path to your home directory.

  SHELL="$HOME/bin/bash-3.2.48/bin/bin/bash"
  exec "$SHELL"

Adding a check for that shell existing would probably be wise.

  SHELL="$HOME/bin/bash-3.2.48/bin/bin/bash"
  if [ -x "$SHELL" ]; then
    exec "$SHELL"
  fi
  echo "Unable to exec my custom shell."

Or if your $HOME isn't sufficient then you would need to write it out
in long form.

  SHELL="/first/path/to/check/for/bash-3.2.48/bin/bash"
  if [ -x "$SHELL" ]; then
    exec "$SHELL"
  else
    SHELL="/some/other/path/to/bash-3.2.48/bin/bash"
    if [ -x "$SHELL" ]; then
      exec "$SHELL"
    fi
  fi
  echo "Unable to exec my custom shell."

Bob


Reply via email to