1

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

./shell_gen.csh test1 test2.prt

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

任何人?

谢谢

生成.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
4

2 回答 2

2

我会说当它们与其他一些字符连接时,您可能需要在位置参数变量周围放置花括号:

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

但是你可能也想要一个点:

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

和引号防止空格。

于 2009-09-17T20:55:47.723 回答
1

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

您是否按照丹尼斯的建议尝试了 ${1}gif?我认为这应该有效。

此外,尽管您的 generate 清楚地发送了第二个参数,但我在任何地方都没有看到对 $2 的引用。

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

最好的,
-pbr

于 2009-09-25T21:40:17.810 回答