Re: login into a particular directory using ssh
On Sun, Dec 05, 2004 at 05:35:59PM -0500, Kamaraju Kusumanchi wrote:
> On Sun, 5 Dec 2004 23:28:07 +0100, Maurits van Rees <maurits@vanrees.org> wrote:
> > On Sun, Dec 05, 2004 at 05:18:54PM -0500, David Mandelberg wrote:
> > > ssh user@hostname "sh -c 'cd dirname; exec somecommand'"
> > >
> > > somecommand is the command you want to run after cd'ing. E.g. if you
> > > want to run bash in / as joe at shell.example.net:
> > >
> > > ssh joe@shell.example.net "sh -c 'cd /; exec bash'"
> >
> > Alternatively, if you *always* want to start in that directory, you
> > can edit the .bash_profile or similar on the remote machine. Just add
> > `cd <some directory>'.
> >
>
> No, I want this to happen only when I ssh. If i edit the bash_profile,
> then everytime I open a window/shell, it gets executed. That is not
> what I want.
>
I'm ssh'ed in right now and see that the following variables are set:
SSH_CLIENT=<stuff>
SSH_CONNECTION=<more stuff>
SSH_TTY=/dev/pts/0
You probably could wrap your cd command with a conditional testing for one
of these.
HTH
dt
--
Dave Thayer | WARNING: Persons denying the existence of
Denver, Colorado USA | robots may be robots themselves.
dave@thayer-boyle.com |
Reply to: