未找到linux问题setenv命令(linux issue setenv command not found)

我在Linux中开发了一个Tcl / Tk脚本工具。 为了运行该工具,每次需要在shell中设置这样的环境变量时:

setenv LD_LIBRARY_PATH /opt/lsf/9.1/linux2.6-glibc2.3-x86_64/lib:/abc/software/new_2015/GE/tcl_tk/lib64:/abc/software/new_2015/GE/tcl_tk/lib64

然后使用“希望”解释器启动我的工具:

/abc/software/new2015/GE/tcl_tk/bin/wish mytool.tk

为了使它容易使用,我想要设计一个shell脚本“abc_wish”并将上面的命令放在里面:

#!/bin/sh
setenv LD_LIBRARY_PATH /opt/lsf/9.1/linux2.6-glibc2.3-x86_64/lib:/abc/software/new_2015/GE/tcl_tk/lib64:/abc/software/new_2015/GE/tcl_tk/lib64
wish="/abc/software/new2015/GE/tcl_tk/bin/wish"
exec $wish $@

然后我需要运行:

./abc_wish mytool.tk

但错误信息显示setenv命令没有找到!我对这些系统问题完全陌生,需要一些关于这些东西的帮助。 希望我已经清楚地表明了这个问题。

I develop a Tcl/Tk script tool in Linux. In order to run the tool, every time I need to set the environment variable like this in shell:
setenv LD_LIBRARY_PATH /opt/lsf/9.1/linux2.6-glibc2.3-x86_64/lib:/abc/software/new_2015/GE/tcl_tk/lib64:/abc/software/new_2015/GE/tcl_tk/lib64
and then use "wish" interpreter to launch my tool:
/abc/software/new2015/GE/tcl_tk/bin/wish mytool.tk
To make it a little easy to use, I want design a shell script "abc_wish" and put the above command inside:
#!/bin/sh
setenv LD_LIBRARY_PATH /opt/lsf/9.1/linux2.6-glibc2.3-x86_64/lib:/abc/software/new_2015/GE/tcl_tk/lib64:/abc/software/new_2015/GE/tcl_tk/lib64
wish="/abc/software/new2015/GE/tcl_tk/bin/wish"
exec $wish $@
And then I need just run:
./abc_wish mytool.tk

But error message shows that setenv command not found!I am totally new to such system issues, need some help about these stuffs. Hope I have shown the issue clearly.

原文:https://stackoverflow.com/questions/27737224

更新时间:2020-01-14 08:15

最满意答案

setenv是一个csh命令,而不是sh命令。 bash的等价物是export :

#!/bin/sh
export LD_LIBRARY_PATH=/opt/lsf/9.1/linux2.6-glibc2.3-x86_64/lib:/abc/software/new_2015/GE/tcl_tk/lib64:/abc/software/new_2015/GE/tcl_tk/lib64
exec wish "$@"

您还应该在报价中加入$@ ,以确保正确地重新引用扩展。

setenv is a csh command, not a sh command. The equivalent in bash is export:
#!/bin/sh
export LD_LIBRARY_PATH=/opt/lsf/9.1/linux2.6-glibc2.3-x86_64/lib:/abc/software/new_2015/GE/tcl_tk/lib64:/abc/software/new_2015/GE/tcl_tk/lib64
exec wish "$@"
You should also put $@ in quote, to ensure proper re-quoting of the expansion.

2015-01-02