PATH in clish shell

816 views
Skip to first unread message

hitchcocknz

unread,
Jan 11, 2012, 7:05:11 PM1/11/12
to klish
Hi all,

I have set the shell type for a specific user to be clish. When I
login as that user clish is indeed the shell. My question is perhaps
more linux based but I am not sure. How does the environment variable
PATH get set when I SSH remotely into the box as this specific user.

Most of the stuff on the net is about launching bash shells and its
behaviour which doesn't seem to be relevant here. I thought that
maybe the /etc/login.defs file might be the basis for the shell's
settings but this doesn't appear to be the case. I have even tried to
grep for the part of the pathname that the PATH seems to be set to but
can't find a configuration file that contains it.

Any thoughts would be greatly appreciated.

Shane

Serj Kalichev

unread,
Jan 12, 2012, 5:12:35 AM1/12/12
to kl...@googlegroups.com
Hi

The bash (for example) can be "login shell" or "common shell".
Login shell is the first instance of bash. This instance have no shell parents.
So it use /etc/profile (and probably .profile) and .bashrc files to init.
Common shell use only .bashrc file.
You can force bash to be login shell by -l option.

For ssh login with clish I use wrapper named "dish"
The dish do something like this:
# Include profile. The dish can be standalone.
test -r /etc/profile && . /etc/profile
# Include dish config file.
test -r /etc/dish && . /etc/dish
...
exec /usr/bin/clish "$@"

So I use /bin/dish as a default shell but not clish itself

2012/1/12 hitchcocknz <hitch...@gmail.com>:

hitchcocknz

unread,
Jan 13, 2012, 4:28:57 AM1/13/12
to klish
Thanks Serj that's clear. I'm still missing something though.

So I set the PATH correctly in the .profile (export PATH=.....) and
check it by running 'env' and then exec the clish.

I have the following command in CLISH xml file

<COMMAND name="test"
help="Test command">
<DETAIL>
Usage: Test
</DETAIL>
<ACTION>env</ACTION>
</COMMAND>

So when 'test' command is entered it launches an interative non-login
bash shell, runs env and then returns. Problem is the PATH is not
what I want. The PATH should either be the parent processes PATH
(which is what I want) or it is modified by some startup script - is
that correct? I can't see any script that is setting the PATH to the
value it gets unfortunately and I have looked fairly extensively at
all the possible bash startup scripts. Maybe CLISH is launching a
bash shell but some other shell?

Any flaws in my understanding ?

Cheers
Shane


On Jan 12, 11:12 pm, Serj Kalichev <serj.kalic...@gmail.com> wrote:
> Hi
>
> The bash (for example) can be "login shell" or "common shell".
> Login shell is the first instance of bash. This instance have no shell parents.
> So it use /etc/profile (and probably .profile) and .bashrc files to init.
> Common shell use only .bashrc file.
> You can force bash to be login shell by -l option.
>
> For ssh login with clish I use wrapper named "dish"
> The dish do something like this:
> # Include profile. The dish can be standalone.
> test -r /etc/profile && . /etc/profile
> # Include dish config file.
> test -r /etc/dish && . /etc/dish
> ...
> exec /usr/bin/clish "$@"
>
> So I use /bin/dish as a default shell but not clish itself
>
> 2012/1/12 hitchcocknz <hitchcoc...@gmail.com>:

Serj Kalichev

unread,
Jan 13, 2012, 4:49:48 AM1/13/12
to kl...@googlegroups.com
Hi

It's strange.
I have tested the env variables now. It woks for me. And PATH works too.
The clish use /bin/sh as a default shell.
Additionally see the http://code.google.com/p/klish/wiki/shebang for
information about shebang settings.
Check the /bin/sh file. It can be a symbolic link for another shell
(dash for example in Debian), Another shell can use its own additional
config files like .bashrc for bash. Probably it can redefine PATH
within this config...

2012/1/13 hitchcocknz <hitch...@gmail.com>:

hitchcocknz

unread,
Jan 13, 2012, 6:21:28 PM1/13/12
to klish
Hi,

/bin/sh does indeed link to dash (I am debian).

I have solved the problem by using the ~/.profile file to set the path
and then exec clish ie. conventional approach

However interestingly, creating a "dish" script as follows gives
issues with the PATH variable:

#!/bin/sh

#Include profile
test -r /etc/profile && ./.profile

#Launch clish
exec /usr/local/bin/clish "$@"


I added to ~/.profile the commands:
PATH=$PATH:/shane
export PATH
env

and indeed if I ssh in env shows the correct path ie. before exec
clish. However the exec clish shell has some default PATH variable
setting from somewhere??? It doesn't take on the parent setting. The
same occurs if I exec /bin/sh (ie dash shell). So there is something
different about the login shell being set to a script file as opposed
to the shell executable itself. For a non-login interactive dash
shell, dash doesn't run any scripts by default so it is all a bit
strange.

Anyway - as I said I solved the problem so thanks for your help and
pointers.

Cheers
Shane



Serj Kalichev

unread,
Jan 14, 2012, 10:28:16 AM1/14/12
to kl...@googlegroups.com
Hi.

It's really strange. The clish doesn't change PATH itself. And the
script from ACTION inherits previous environment while my experiments.
I suppose ssh daemon set some default PATH but when it's a clish
nobody include .profile then. In case of /bin/sh (default shell) it
will include .profile etc.

2012/1/14 hitchcocknz <hitch...@gmail.com>:

Reply all
Reply to author
Forward
0 new messages