Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run csh scripts from bash, change shell temporary via command

Tags:

linux

bash

tcsh

I need to run csh scripts from a bash shell and therefore temporary change to tcsh via a command. It works perfect in interactive mode but i cant figure out in a one line command. So in interactive mode i do in the bash shell:

tcsh

source my.tcshr

useMyTcshCmd

etc.

How can i do all of this in 1 command? Sorry for the newbie question...

like image 288
user501743 Avatar asked Nov 09 '10 10:11

user501743


People also ask

How do I change a shell from bash to csh?

In the terminal, use the chsh command and use it to swap from Bash (or whatever Shell you are using) to Tcsh. What is this? Entering the chsh command in a terminal will print out “Enter the new value, or press ENTER for the default” on the screen.

How do I change the shell prompt in bash?

You can change the BASH prompt temporarily by using the export command. This command changes the prompt until the user logs out. You can reset the prompt by logging out, then logging back in.

Can I change bash script while running?

with the current version of bash, modifying a script on-disk while it is running will cause bash to "try" to load the changes into memory and take these on in the running script. if your changes come after the currently executing line, the new lines will be loaded and executed.


2 Answers

tcsh -c "echo foo; echo bar"

Result:

foo
bar

So this should work:

tcsh -c "source my.tcshr; useMyTcshCmd"
like image 53
Tometzky Avatar answered Sep 21 '22 18:09

Tometzky


You should specify the interpreter directly in the script:

#!/usr/bin/tcsh
echo "doing stuff"

And then simply run the script:

./script
like image 37
Šimon Tóth Avatar answered Sep 24 '22 18:09

Šimon Tóth