Thread: diff shells

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    Phoenix
    Posts
    5
    Rep Power
    0

    Exclamation diff shells


    Is there any way to programmatically determine what shell (sh, ksh csh,...) you are in?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    137
    Rep Power
    0
    echo $SHELL
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    Phoenix
    Posts
    5
    Rep Power
    0
    $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.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    137
    Rep Power
    0
    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.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    USA
    Posts
    334
    Rep Power
    11
    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
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    India
    Posts
    61
    Rep Power
    11
    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.
    Last edited by jayakhanna; December 23rd, 2003 at 09:51 PM.
    Regards
    JK

IMN logo majestic logo threadwatch logo seochat tools logo