Default shell for executing scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Default shell for executing scripts
# 1  
Old 01-10-2011
Question Default shell for executing scripts

Hi there,

And happy new year to everyone.
I was wondering how is set the default shell for executing scripts.
I mean when the first line of a script file is not
Code:
#!/bin/bash

Then what shell will be used to execute the script?
I thought the script file would be parsed using the current shell but the following shows that this is not the case:
Code:
santiago@ks354286:~$ readlink /proc/$$/exe # I'm currently using bash
/bin/bash
santiago@ks354286:~$ tcsh # I go into tcsh
ks354286:~> cat /tmp/test
readlink /proc/$$/exe
ks354286:~> /tmp/test
/bin/bash

Why would bash be used to run the script if my current shell is tcsh?

Can anyone help me?
Thanks in advance.

Santiago
# 2  
Old 01-10-2011
Off the top of my head . . .

Probably because you invoked tcsh from within bash.

Try logging in as a user with /bin/tcsh as their default and see what you get.
# 3  
Old 01-10-2011
Hi Beaknit,

And thanks for helping.
I just changed my default shell to /usr/bin/tcsh in /etc/passwd and logged in again.
The defauly shell used to run the scripts is still /bin/bash.

Any other idea ?
Santiago
# 4  
Old 01-12-2011
What kind of system are you using?

Distro, version, uname, etc

And can you post the script?

Also - sanity check: are you running it under cron?
# 5  
Old 01-12-2011
depending on your default SHELL and how your system is setup, some config file may run as well (.bashrc in bash, .kshrc , .login, $HOME/.profile , /etc/profile, .... and so on).

they may change things.

you should logon with the shell that is defined in the /etc/passwd but if that shell run some environment file, those can change things (depending on what is setup into it).

when you are in bash,

instead of running
Code:
tcsh

try running :
Code:
exec tcsh

Do you see the difference ?

(in the first case it will make tcsh be a subprocess of the initial bash process, check it with ptree $$ or pstree $$ depending on your OS in the other case, it will make it the initial process)

Last edited by ctsgnb; 01-12-2011 at 08:57 AM..
# 6  
Old 01-12-2011
This might not be true, or appliable to other Unices, but I think the default shell for scripts in Linux is /bin/sh, which is usually just a copy of or link to /bin/bash.
# 7  
Old 01-12-2011
What is the output from:
Code:
ls -lisad /usr/bin/tcsh
ls -lisad /usr/bin/bash

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Executing scripts on remote servers

Hello all, I'm typing away a script that will send a script to a remote host and execute it. This is what i have at the moment and i was wondering if i can improve that or thats basicly what everybody does. Using bash on RHEL 5.5 To over simplify it... #!/bin/bash # start_ () { ... (3 Replies)
Discussion started by: maverick72
3 Replies

2. Shell Programming and Scripting

Shell scripts exits after executing ypmatch

Hello - I have a script which creates a NIS user on Solaris machine. Before creating the user I check if the user being created laready exists or not using ypmatch and use $? to get the exit code. If a user exists, I get 0, works fine. However when the user is not found, the shell scripts exits by... (1 Reply)
Discussion started by: manju--
1 Replies

3. Shell Programming and Scripting

Executing all scripts in /DIR except one

First i need to find all scripts directly under /DIR that end with ".sh" extension except "noallow.sh". That can be done with: find /DIR -maxdepth 1 -name "*.sh"|grep -v "noallow.sh" Now i want to run all the files output from the previous command. The following code: for filename in... (6 Replies)
Discussion started by: proactiveaditya
6 Replies

4. Shell Programming and Scripting

Executing several bash scripts in succession

Hi, I am new to shell programming. I am trying to automate setting up a network using several scripts. Some of the scripts require to reboot in order to continue with the setup. Is it possible to enter another script as soon as the system reboots. Also, if the last line of the script is bash... (7 Replies)
Discussion started by: fantasyland
7 Replies

5. Shell Programming and Scripting

executing shell scripts in a browser

Hi all Im a newbie in shell scripting, i found it joyous creating simple adminitrative scripts, like adding users, modify and delete, remote sw install etc, now i want to intergrate my scripts to make a simple administrative tool, how do i access the scripts via a browser is it possible?? ... (2 Replies)
Discussion started by: jefinah
2 Replies

6. UNIX for Dummies Questions & Answers

Executing scripts in back ground

Hi, Test1.ksh #! /bin/ksh for i in $* do #echo "$i" ksh test2.ksh $i & done test2.ksh #! /bin/ksh sleep 5s echo "From Test 1 ==> $1" exit 0; I am executing as follows: ksh test1.ksh a b c (10 Replies)
Discussion started by: risshanth
10 Replies

7. Shell Programming and Scripting

Executing scripts in Parallel

Hi All, I have 3 shell scripts, Script1,Script2 and Script3. Now I want to run Script1 and Script2 in parallel and Script3 should depend on successful completion of both Script1 and Script2. Could you please suggest an approach of acheiving this... Thanks in advance (2 Replies)
Discussion started by: itsme_maverick
2 Replies

8. UNIX for Dummies Questions & Answers

Executing Shell Scripts

Hi, I'm pretty new to Unix and I just have a question concerning making a script executable without putting the "sh" command before it. In case it makes the difference I am on an Apple computer using the Terminal. Anyway here is the little test code I wrote followed by the commands I took to try... (1 Reply)
Discussion started by: BuyoCat
1 Replies

9. Shell Programming and Scripting

executing variables in ksh scripts?

In a ksh script on an AIX box running a jillion oracle database processes, I'm setting a variable to one of two possible arguments, depending on cmd line arguments. FINDIT="ps -ef | grep oracle | grep DBexport | grep rshrc" -or- FINDIT="ps -ef | grep oracle | grep prod | grep runback" I... (3 Replies)
Discussion started by: zedmelon
3 Replies

10. UNIX for Advanced & Expert Users

executing perl scripts

Does anybody experiencing this same problem? I am using IRIX64 ver 6.5 at work. I wrote some Perl scripts and to execute it. First I try to put the Perl script at: /$HOME/bin/perlscript then I set the correct executable 755 right to the file I make sure the PATH to the executable... (2 Replies)
Discussion started by: vtran4270
2 Replies
Login or Register to Ask a Question