views:

969

answers:

2

So I have .csh script generate.csh I want to call another .csh script from within it. I tried

./shell_gen.csh test1 test2.prt

But it runs shell_gen.csh but without command line arguments.

Anyone?

Thanks

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
+1  A: 

I would say you probably need to put curly braces around the positional parameter variable when they are concatenated against some other characters:

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

But you might want a dot in there, too:

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

and quotes protect against spaces.

Dennis Williamson
that part works....when I run from command line the script ./shell_gen.csh test test1.prtit works fine...when its called from script above it doesnt work
grobartn
+1  A: 

$1gif isn't a reference to a positional parameter.

Did you try ${1}gif as Dennis suggested? I think that should work.

ALSO I see no reference to $2 anywhere though your generate clearly sends a second argument.

Lastly the first line should probably be #!/bin/csh -f

Best,
-pbr

pbr