所以我有.csh脚本generate.csh 我想从其中调用另一个.csh脚本。 我试过了

./ shell_gen.csh test1 test2.prt

但它运行shell_gen.csh但没有命令行参数。

任何?

由于

generate.csh

#!/bin/csh
./shell_gen.csh test1 test2.prt

shell_gen.csh

#!/bin/csh
set source = output
############################################################
# create pbm-gifs/ directory
############################################################
set destination1 = /scratch/graphics/$1gif
echo making $destination1

if ( ! -e $destination1 ) then
  mkdir $destination1
  foreach file ( $source/*.pgm )
    echo convert $file $destination1/$file:t:r.gif
    convert $file $destination1/$file:t:r.gif
end
else
echo "$destination1/ exists"
endif
有帮助吗?

解决方案

我会说你可能需要在位置参数变量与其他一些字符连接时将花括号括起来:

set destination1 = /scratch/graphics/${1}gif

但你也可能想要一个点:

set destination1 = "/scratch/graphics/${1}.gif"

和引号可以防止空格。

其他提示

$ 1gif不是对位置参数的引用。

你有没有像丹尼斯建议的那样尝试$ {1} gif?我认为这应该有效。

虽然你的生成器明确发送了第二个参数,但我在任何地方都没有看到$ 2的引用。

最后第一行应该是#!/ bin / csh -f

最佳,结果 -pbr

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top