setenv not working in tcsh

7,211

This script is not actually being executed by tcsh. You ran the command ./setup.csh from tcsh, but that is a separate command, executed in its own process. There is no reason from what you've shown that the script would be executed in tcsh. The command setenv is not found because some different interpreter is executing the script. As further evidence the error messages are consistent with bash, dash and ksh's error message formatting, but not with tcsh's.

This is a bug in the script. It should start with a shebang line indicating which interpreter (shell) the script is designed for. A tcsh script should start with the line

#!/usr/bin/env tcsh

Add this line (it must be the very first line; note that the file must not have Windows line endings, so take care if you use a Windows editor, or better, use a Linux editor). Alternatively, if you prefer not to edit the file, you can invoke tcsh explicitly:

tcsh ./setup.csh

You can do that from any shell, you don't have to use tcsh interactively if you don't want to.

Share:
7,211

Related videos on Youtube

Anna
Author by

Anna

Updated on September 18, 2022

Comments

  • Anna
    Anna almost 2 years

    I am trying to install a program on my brand-new CentOs. The installation requires setenv, which apparently does not work, not even in the tcsh shell.

    Can anyone give me some advice?

    [Anna@anna xd-demo] ./setup.csh
    
    Configuring shell for the XD2006 :
    ./setup.csh: line 7: setenv: command not found
    ./setup.csh: line 8: setenv: command not found
    ./setup.csh: line 9: setenv: command not found
    ./setup.csh: line 10: setenv: command not found
    ./setup.csh: line 11: syntax error near unexpected token `('
    ./setup.csh: line 11: `set path=( $XD_ROOT/bin $XD_ROOT/lib/xd $XD_ROOT/lib/xdgraph $path )'
    [Anna@anna xd-demo]$ echo $shell
    /bin/tcsh
    
    • schaiba
      schaiba almost 10 years
      echo $shell should return nothing. What you want is $SHELL. So please make sure you have (t)csh correctly installed and running.