1

したがって、.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
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を試しましたか?私はそれがうまくいくはずだと思います。

また、あなたの生成物は明らかに2番目の引数を送信しますが、$2への参照はどこにもありません。

最後に、最初の行はおそらく#!/ bin /csh-fである必要があります

最高、
-pbr

于 2009-09-25T21:40:17.810 に答える