Wednesday, June 6, 2012

Shell

How I can know which shell is used by operating system solaris 10? C or KSH or bash??? 
I am new to sun environment.








Look at what root is assigned in the /etc/passwd. If you want a job to run under a different shell you can specify that in the cron. 


Try printenv | grep SHELL 
The /etc/passwd file sets the shell for root and by default it is /bin/sh. 
At the prompt type bash you will be in the bash shell 
In most cases you are in KSH shell> 
> How I can know which shell is used by operating system solaris 10? C or KSH or bash??? 
> I am new to sun environment. 
echo $SHELL 
All are available, which is assigned to a user is controlled by their 
/etc/passwd entry and can be modified with usermod (see "man usermod"). 
you can find the shell by using the below command. 
# echo $0
while i execute the command #printenv 
bash: printenv: command not found 
  You can try one of the following ,the two answers are true: 
1) 
""""from the command line issue : 
$ echo $SHELL 
The system will respond with this : 
/bin/sh 
2) 
"""from the command line ,issue : 
$ printenv | grep SHELL 
SHELL=/bin/sh 
 
  You can use 
echo $SHELL 
It will return which shell you are using 
We can use any of these shells. We can tell the OS which shell to use, 
while creating the user 
find this in /etc/password file  
  Note: This answer is for the Solaris OS. 

All of the previous answers require your shell to set specific environment variables to get the answer. This does not always occur. 

The best previous answer is the "echo $0" as all shells set this variable. The $0 variable is set to the name of the script that is running the current commands. As such, in an interactive environment, the "script" would be the shell you are working in. However, csh tries to identify the full path to the script file and sometimes can not resolve this to the full path of the shell. When it can't it answers "No file for $0". As such, it is not a "100% of the time" answer. 

The only way I can think of that will work 100% of the time is the following: 

ps -ef | grep $$ | egrep -v 'ps -ef|grep' 

The $$ variable is always set to the PID of the parent process. The parent process in the case of an interactive shell is the shell itself. This will work is all shells. 
The answer is much sampler. The command to get current shell is echo $SHELL 
  $SHELL does not always get set. On average, I would say 80% of the time. 

That was my point. The only 100% solution is the $$ command. 
  I thought $SHELL shows the default shell - if you've changed shell during your seesion $0 shows the current shell 


Wayne 


This e-mail contains confidential information and is for the exclusive use of the addressee/s. If you are not the addressee, then any distribution, copying or use of this e-mail is prohibited. If received in error, please advise the sender and delete it immediately. We accept no liability for any loss or damage suffered by any person arising from use of this e-mail. 



0 comments:

Post a Comment

 
Design by BABU | Dedicated to grandfather | welcome to BABU-UNIX-FORUM