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

Re: login into a particular directory using ssh



On Sun, Dec 05, 2004 at 08:19:04PM -0500, Kamaraju Kusumanchi wrote:
> bash$export DYNAMIC=$(basename $PWD)
> bash$ssh -t joe@shell.example.net 'cd $DYNAMIC && exec /bin/bash --login -i'

how about:

  ssh -t joe@shell.example.net "cd $PWD ; exec /bin/bash --login -i"

I don't know what you were using basename for, that would mean it would try to
cd to only the last part of the directory name, not the full path.  In most
cases, this would fail.

The above works for me - assuming the directory you're in on the local machine
exists on the remote machine.  If it doesn't, you'll get an error message and
be dumped in $HOME.

If your home directory has a different path on the two machines, try this:

  DYNAMIC=${PWD#$HOME/}
  ssh -t joe@shell.example.net "cd $DYNAMIC ; exec /bin/bash --login -i"

This should plunk you in the corresponding directory on the remote host,
whether you're in $HOME/foo or /usr/bin.  You don't need to export DYNAMIC.


Sam



Reply to: