LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Having trouble running tsch script in bash (http://www.linuxquestions.org/questions/linux-general-1/having-trouble-running-tsch-script-in-bash-841928/)

protolocke 11-02-2010 11:55 AM

Having trouble running tsch script in bash
 
I've got this simple script called test1, which I'm trying to execute in a bash shell using ./test1

Code:

#!/bin/tcsh
echo 'Hello world!'

But I can't get it to work. When I run it, nothing happens. I've checked and I definitely have tcsh in /bin. I also used
Code:

chmod +x
to make it executable. The script only works if I replace the top line with
Code:

#!/bin/bash
instead. Am I missing something?

Any help is appreciated

udaman 11-02-2010 12:05 PM

Do you think that might be because you're running the bash shell at login, and not the tcsh? Start tcsh, at the bash prompt, then run the script.

Code:

#tcsh
Edit: it works fine on my system, even if I'm running bash, and using #!/bin/tcsh

MensaWater 11-02-2010 12:17 PM

Works fine for me on CentOS5. Running the script from command line (bash) worked fine. Creating a script with a #!/bin/bash interpreter that in turn called the above script also worked fine.

This suggests the issue may be with your system. What does "file /bin/tcsh" show? Have you verified /bin/tcsh isn't a symbolic link to something else?

What happens if you simply switch shells by typing "tcsh" at command prompt then type in "echo 'Hello world!'?

protolocke 11-02-2010 12:22 PM

I figured out what the problem was, my ~/.tcshrc file had this in it:
Code:

bash
Woops, sorry guys I forgot about this! I'm using linux on a university computer and set up a workaround back in September to start bash, as tcsh was the default shell.


All times are GMT -5. The time now is 12:04 AM.