在 tcsh 中获取 sh 文件是非法的

在 tcsh 中获取 sh 文件是非法的

解决后首先,我尝试编辑 sh 脚本csh.cshrc。我在脚本末尾添加了以下几行:

. /etc/fsl/5.0/fsl.sh
setenv FREESURFER_HOME/home/User/freesurfer
source $FREESURFER_HOME/SetUpFreeSurfer.csh

但是我得到了错误/usr/sbin/.: Permission denied.。我尝试将其更改为source /etc/fsl/5.0/fsl.shbt,然后我得到了错误Illegal variable name.

我尝试获取的文件是:

# FSL configuration file
#  - to be sourced by the user, typically in .bashrc or equivalent
#  - note that the user should set
# Written by Mark Jenkinson, FMRIB Analysis Group, University of Oxford
# Modified for Debian by Michael Hanke <[email protected]>

# clean out previous fsl PATH components: DO NOT EDIT THE NEXT TWO LINES
PATH=$( echo $PATH | tr ":" "\n" | grep  -v "/usr/lib/fsl/" | tr -s "\n" ":" | sed  's/:$//') 
LD_LIBRARY_PATH=$( echo $LD_LIBRARY_PATH | tr ":" "\n" | grep  -v "/usr/lib/fsl/" |  tr -s "\n" ":" | sed 's/:$//')

#### Set up standard FSL user environment variables ####

# Debian has a fixed FSLDIR
FSLDIR=/usr/share/fsl/5.0

# Possum is installed in the same directory
POSSUMDIR=$FSLDIR

# add the fsl binary path to the search path
PATH=$PATH:/usr/lib/fsl/5.0

# The following variable selects the default output image type
# Legal values are:
# NIFTI, NIFTI_PAIR, NIFTI_GZ, NIFTI_PAIR_GZ
# This would typically be overwritten in ${HOME}/.fsl/fsl.sh if the user
# wished to write files with a different format
FSLOUTPUTTYPE=NIFTI_GZ

# Comment out the definition of FSLMULTIFILEQUIT to enable
#  FSL programs to soldier on after detecting multiple image
#  files with the same basename ( e.g. epi.hdr and epi.nii )
FSLMULTIFILEQUIT=TRUE

# The following variables specify paths for programs and can be changed
# or replaced by different programs, by default set sensible Debian-defaults
FSLTCLSH=/usr/bin/tclsh
FSLWISH=/usr/bin/wish
FSLBROWSER=/etc/alternatives/x-www-browser

# The following variables are used for running code in parallel across
#  several machines ( i.e. for FDT )
# for a cluster engine setup see below
FSLLOCKDIR=
FSLMACHINELIST=
FSLREMOTECALL=

# If set, tell FSL to use Sun Gridengine to submit jobs instead of running them
# directly on the machine. If unset, no attempt will be made to utilize
# gridengine, even if it is running. By default SGE is not utilized.
#FSLPARALLEL=1

# Mail setup for gridengine jobs. See man qsub (-m option) for all possible
# settings. By default no email is sent.
FSLCLUSTER_MAILOPTS="n"

# default queue for job submissions
#FSLCLUSTER_DEFAULT_QUEUE="all.q"

###################################################
####    DO NOT ADD ANYTHING BELOW THIS LINE    ####
###################################################

export FSLDIR POSSUMDIR PATH FSLMULTIFILEQUIT FSLOUTPUTTYPE FSLTCLSH \
       FSLWISH FSLBROWSER FSLLOCKDIR FSLMACHINELIST FSLREMOTECALL


# Configure the linker search path for Debian FSLs internal shared libraries
LD_LIBRARY_PATH=/usr/lib/fsl/5.0${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export LD_LIBRARY_PATH

# load user configuration
if [ -f "${HOME}/.fslconf/fsl.sh" ] ; then
"${HOME}/.fslconf/fsl.sh" ;
fi

我如何运行该脚本?

答案1

问题在于,您获取的文件是 tcsh 不支持的 bashisms/shisms 的混合,首先从您声明变量的方式开始:

PATH=$( echo $PATH | tr ":" "\n" | grep  -v "/usr/lib/fsl/" | tr -s "\n" ":" | sed  's/:$//') 

这在 tcsh 中不起作用。您必须将其修改为:

set PATH = `echo $PATH | tr ":" "\n" | grep  -v "/usr/lib/fsl/" | tr -s "\n" ":" | sed  's/:$//'`

在这种情况下,有两个变化。您必须明确说明要使用 设置变量set,并且 tcsh 不支持$(...)子 shell,因此您需要使用反引号`...`

另外,if..else是错误的,应该是:

if (-f "${HOME}/.fslconf/fsl.sh") then
  "${HOME}/.fslconf/fsl.sh" ;
endif

应该可以了。完整参考资料可以在卵子

哦,忘了补充,因为set是明确的,所以你不需要任何export VAR。只需将其删除即可。

相关内容