|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Is there any way to programmatically determine what shell (sh, ksh csh,...) you are in?
|
|
#2
|
|||
|
|||
|
echo $SHELL
|
|
#3
|
|||
|
|||
|
$SHELL is initialized ( in our system!) only in the login script; i.e. it does not change if when you switch shells. Thus I need someway to tell what shell I am in. And, although this seems odd I do not want to manipulate any variables manually.
|
|
#4
|
|||
|
|||
|
I don't know of any command that will tell you that
Only way that I know of, besides the $SHELL that you can't use, is to be a bit creatif and write a script. |
|
#5
|
|||
|
|||
|
Nobody has said it up to now but ...
There is something very wrong with the way you are doing/thinking about shell scripts if you need to know programatically what shell you are in. Sounds like you wish to use shell features which are not available or differ in the various shells. Bad idea! If you want portable shell scripts you should be using the POSIX shell or ksh88. - Finnbarr |
|
#6
|
|||
|
|||
|
ps | grep `echo $$` | awk '{ print $4 }'
This will tell you the current shell in which you are working ps will show all the processes, including the shells which are opened, echo $$ will give the current shells process id and then we can grep and print it using awk.
__________________
Regards JK Last edited by jayakhanna : December 23rd, 2003 at 09:51 PM. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > diff shells |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|