Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何确定脚本要使用的shell?_Shell - Fatal编程技术网

如何确定脚本要使用的shell?

如何确定脚本要使用的shell?,shell,Shell,我有一个不起作用的脚本,在我尝试修复它之前,我需要知道它应该在什么样的shell中运行 # set pwrs = ( 0 0 0 0 0 0 0 0 ) @ pwrs[1]=1 @ next=2 while ( $next < 9 ) @ last = $next - 1 @ pwrs[$next] = $pwrs[$last] * 2 @ next = $next + 1 end @count = 1 while ( $count <

我有一个不起作用的脚本,在我尝试修复它之前,我需要知道它应该在什么样的shell中运行

#
set pwrs = ( 0 0 0 0 0 0 0 0 )
@ pwrs[1]=1
@ next=2
while ( $next < 9 )
        @ last = $next - 1
        @ pwrs[$next] = $pwrs[$last] * 2
        @ next = $next + 1
end

@count = 1
while ( $count <= 8 )
        echo $pwrs[$count]
        @ count = $count + 1
end
#
设置pwrs=(0 0 0)
@压水堆[1]=1
@下一个=2
而($next<9)
@last=$next-1
@压水堆[$next]=$pwrs[$last]*2
@next=$next+1
结束
@计数=1

虽然($count我能够使用
csh
生成适当的输出。我希望
tcsh
也能工作

结果我确实有一个csh可用。我将代码粘贴到了cmdline中

有一个错误。所有以
@
字符开头的数学计算必须与其下面的变量名分开,因此

@count = 1
需要固定为

@ count = 1

$ set pwrs = ( 0 0 0 0 0 0 0 0 )
$ @ pwrs[1]=1
$ @ next=2
$ while ( $next < 9 )
while?         @ last = $next - 1
while?         @ pwrs[$next] = $pwrs[$last] * 2
while?         @ next = $next + 1
while? end

$ @ count = 1
$ while ( $count <= 8 )
while?         echo $pwrs[$count]
while?         @ count = $count + 1
while? end
有关csh
@
$pwrs[$next]
(数组表示法)的解释,请参阅。您的特定案例没有得到解决,但您应该能够解决它。如果在构建小测试案例后,您有其他问题无法解决,请将它们与示例输入、预期输出以及当前代码和输出一起发布

此外,不要在CSH上花费更多的时间,而不是像一些描述它那样糟糕,你最终会发现在CSH中你不能解决的问题。所有好的CMD线特征都包含在BASH中,所以你可能想考虑使用它。最后,看看为什么要将这个代码转换成新的shell的详细原因。


IHTH

很有趣。我不认识这种语言。它不是C shell或Bourne shell的派生语言(不是
bash
ksh
tcsh
,等等)。它不是Perl或Python;我也不认为它是Ruby,尽管我不太确定。它不是
awk
;它不是Tcl/Tk。它是Windows机器上的吗?如果是这样的话,Powershell可能是一种可能性,但对此要谨慎对待;它几乎是一种狂野的(而且大部分是未知的)猜猜。这是在linux中。使用的默认shell是tcsh,但显然不是。我从某处复制了它。我发誓它没有shebang。IDK也许我可以将
@
更改为
$
,看看是否可以运行它then@shellter当前位置
@
符号将是第一个看起来不像C shell的东西,但已经不是了o在(
tcsh
)手册中,我发现它是一个C shell构造,因此-虽然它看起来不像我以前见过的C shell脚本(尽管我没有通过有意识的决定来研究其中的许多脚本)-它很可能是一个C shell脚本。请参阅等等。
1
2
4
8
16
32
64
128
[oracle@localhost ~]$