2009-09-17 75 views
1

所以我有.csh脚本generate.csh 我想从其中调用另一个.csh脚本。 我试图如何使用.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 
+0

可以粘贴脚本? – 2009-09-17 20:31:53

+0

因此'shell_gen.csh'回应“making/scratch/graphics/gif”(即“/”和“gif”之间没有任何内容)?你的脚本适合我(它回应“making/scratch/graphics/test1gif”)。 – 2009-09-18 00:59:38

回答

2

我会说你可能需要把周围的位置参数变量的大括号的时候都对一些级联其他字符:

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

但你可能要在那里一个点,太:

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

和报价防范空间。

+0

该部分工作.... 当我从命令行运行的脚本./shell_gen.csh测试test1.prt 它工作正常......当它从上面的脚本调用不起作用 – grobartn 2009-09-17 21:13:17

1

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

你试过Dennis建议的$ {1} gif吗?我认为这应该工作。

另外,虽然您的生成清楚地发送第二个参数,但我看不到任何地方引用$ 2。

最后的第一行也许应该是#!/ bin中/ CSH -f

最佳,
-pbr