我需要在MacOS X High Sierra上运行NACCESS程序。
最突出的错误是if: Expression Syntax.
该错误可能是因为NACCESS可执行文件是CSH脚本,其第一行带有#!/bin/csh
。
我将第一行更改为#!/bin/bash
并开始收到诸如
./naccess: line 14: syntax error near unexpected token `1'
./naccess: line 14: ` exit(1)'
再次,我认为这是发生的,因为可执行文件需要在CSH Shell中执行,而不是bash。 this resource表示,exit(1)
是针对CSH shell格式化的,而bash则需要exit 1
。
我尝试在Terminal中键入csh
来切换 shell ,但是echo $SHELL
命令只是告诉我我仍然在bash中。
我用grep '^#!' /usr/bin/*
查看了我的shell选择,但是找不到任何CSH shell。我试图使用自制软件下载tcsh
。但是我现在真的不知道我在做什么。
我知道不鼓励使用CSH shell,但是如何在Mac上启动并运行CSH shell,或者如何使NACCESS运行?
[EDIT] 这是NACCESS代码的前几行:
(请注意,我正在使用.pdb文件参数运行它,并且已经正确设置了path_to_naccess_repository。如果仅运行usage naccess pdb_file [-p probe_size] [-r vdw_file] [-s stdfile] [-z zslice] -[hwyfaclqb]
,我确实会得到./naccess
读数)
#!/bin/csh
set EXE_PATH = /path/to/repo
#naccess_start
set nargs = $#argv
if ( $nargs < 1 ) then
echo "usage naccess pdb_file [-p probe_size] [-r vdw_file] [-s stdfile] [-z zslice] -[hwyfaclqb]"
exit(1)
endif
set PDBFILE = 0
set VDWFILE = 0
set STDFILE = 0
set probe = 1.40
set zslice = 0.05
set hets = 0
set wats = 0
set hyds = 0
set full = 0
set asao = 0
set cont = 0
set oldr = 0
set nbac = 0
while ( $#argv )
switch ($argv[1])
case -[qQ]:
echo "Naccess2.1 S.J.Hubbard June 1996"
echo "Usage: naccess pdb_file [-p probe_size] [-r vdw_file] [-s stdfile] [-z zslice] -[hwyfaclq]"
echo " "
echo "Options:"
echo " -p = probe size (next arg probe size)"
echo " -z = accuracy (next arg is accuracy)"
echo " -r = vdw radii file (next arg is filename)"
echo " -s = standard accessibilities file (next arg is filename)"
echo " -h = hetatoms ?"
echo " -w = waters ?"
echo " -y = hydrogens ?"
echo " -f = full asa output format ?"
echo " -a = produce asa file only, no rsa file ?"
echo " -c = output atomic contact areas in asa file instead of accessible areas"
echo " -l = old RSA output format (long)"
echo " -b = consider alpha carbons as backbone not sidechain"
echo " -q = print the usage line and options list"
echo " "
exit
breaksw
case -[pP]:
shift
set probe = $argv[1]
breaksw
case -[zZ]:
shift
set zslice = $argv[1]
breaksw
case -[hH]:
set hets = 1
breaksw
case -[wW]:
set wats = 1
breaksw
case -[yY]:
set hyds = 1
breaksw
case -[rR]:
shift
set VDWFILE = $argv[1]
breaksw
case -[sS]:
shift
set STDFILE = $argv[1]
breaksw
case -[fF]:
set full = 1
breaksw
case -[aA]:
set asao = 1
breaksw
case -[cC]:
set cont = 1
breaksw
case -[lL]:
set oldr = 1
breaksw
case -[bB]:
set nbac = 1
breaksw
default:
if ( -e $argv[1] && $PDBFILE == 0 ) then
set PDBFILE = $argv[1]
endif
breaksw
endsw
shift
end
#
if ( $PDBFILE == 0 ) then
echo "usage: you must supply a pdb format file"
exit(1)
endif
[编辑]我没有正确设置路径>。<所以这个问题主要是关于如何使bsh中的csh脚本运行。这个csh脚本没有问题。
最佳答案
SHELL
变量仅列出您的第一个登录shell,如果您运行另一个shell则不会更改。 echo $0
将显示您正在运行csh
。您可以选择保留bash
并将shebang更改为tcsh
:
#!/usr/bin/tcsh -f
或完全删除shebang并运行
csh ./naccess
如果您要使用第一个选项,并且不确定
csh
在哪里,只需点击which csh
找到路径。正如@Chepner所添加的那样,由于该文件带有
csh
shebang,因此请不要触摸它并按上面的方式运行它。
关于bash - 在bash中运行CSH可执行文件会引发语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52544365/