Search code examples
linuxsetenv

linux issue setenv command not found


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.


Solution

  • 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.