[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:
> On Sun, 05 Dec 2004 18:48:19 -0500, David Mandelberg
> <mandelbergd@eth0.is-a-geek.org> wrote:
> > Miquel van Smoorenburg wrote:
> > >       ssh -t joe@shell.example.net 'cd / && exec /bin/bash'
> > 
> > That works, but because this is a login shell, and the remote machine
> > may differentiate between login and non-login shells, this is better:
> > 
> > ssh -t joe@shell.example.net 'cd / && exec /bin/bash --login -i'
> > 
> > Also don't forget the exec because otherwise you'd be running an extra
> > shell or the single quotes before cd and after -i.
> > 
> 
> This does work perfectly. I am wondering if there is a clever trick to
> do the following.
> 
> In the above examples we are specifying the destination directory. But
> can this directory be obtained from the original machine?
> 
> For example, can I do something like
> 
> bash$export DYNAMIC=$(basename $PWD)
> bash$ssh -t joe@shell.example.net 'cd $DYNAMIC && exec /bin/bash --login -i'
> 
> which dynamically determines the current directory on the ssh client
> and puts me into that directory on the shell.example.net? Needless to
> say, I tried the above example and it does not work.


Do those really have to be single quotes?  If double quotes would work, 
that $DYNAMIC should be interpreted by your local shell, which would 
have the desired effect.  As it stands, the remote shell is looking 
for the variable, which doesn't exist.


-- 
David Jardine

"Running Debian GNU/Linux and
loving every minute of it." -Sacher M.



Reply to: