1

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
  • So shell_gen.csh echoes "making /scratch/graphics/gif" (i.e. nothing between "/" and "gif")? Your script works for me (it echoes "making /scratch/graphics/test1gif"). Commented Sep 18, 2009 at 0:59

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

that part works.... when I run from command line the script ./shell_gen.csh test test1.prt it works fine...when its called from script above it doesnt work
1

$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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.