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:
我需要从bash shell运行csh脚本,因此通过命令临时更改为tcsh。它在交互模式下工作得很完美,但我无法在一行命令中找到答案。所以在交互模式下,我在bash shell中做:
tcsh
source my.tcshr
useMyTcshCmd
etc.
How can i do all of this in 1 command? Sorry for the newbie question...
我如何在1命令中完成所有这些操作?对不起,新手问题......
3 个解决方案
#1
13
tcsh -c "echo foo; echo bar"
Result:
foo bar
So this should work:
所以这应该工作:
tcsh -c "source my.tcshr; useMyTcshCmd"
#2
3
You should specify the interpreter directly in the script:
您应该直接在脚本中指定解释器:
#!/usr/bin/tcsh
echo "doing stuff"
And then simply run the script:
然后只需运行脚本:
./script
#3
0
tcsh -c useMyTcshCmd
#1
13
tcsh -c "echo foo; echo bar"
Result:
foo bar
So this should work:
所以这应该工作:
tcsh -c "source my.tcshr; useMyTcshCmd"
#2
3
You should specify the interpreter directly in the script:
您应该直接在脚本中指定解释器:
#!/usr/bin/tcsh
echo "doing stuff"
And then simply run the script:
然后只需运行脚本:
./script
#3
0
tcsh -c useMyTcshCmd