0

I am using two shell scripts to set up a parallelization. The first script uses a for loop to pass an environment variable to the second script, which makes the call to parallel, which runs a julia script, again passing the variable.

The first (test-loop.sh) script looks like this:

for i in `seq 1 99`;
do 
export my_var=$i

bash  ~/PATH/TO/FILE/test-par.sh 
done

Then the next file (test-par.sh) looks like this:

#!/bin/bash

parallel julia ~/PATH/TO/FILE/bash-test.jl ::: {$my_var..100..1}

This above call to parallel to run Julia works fine if I replace the $my_var with 1 for example, but as soon as I add in the variable, I get the following error:

ERROR: LoadError: ArgumentError: invalid base 10 digit '{' in "{99..100..1}"
Stacktrace:
 [1] tryparse_internal(#unused#::Type{Int64}, s::String, startpos::Int64, endpos::Int64, base_::Int64, raise::Bool)
   @ Base ./parse.jl:137
 [2] parse(::Type{Int64}, s::String; base::Nothing)
   @ Base ./parse.jl:241
 [3] parse(::Type{Int64}, s::String)
   @ Base ./parse.jl:241
 [4] top-level scope

And I don't know how to reformat the call to parallel to fix this problem. Any help greatly appreciated!!

1
  • yes it does!! Thank you! Jan 31 at 18:55

1 Answer 1

0

The easy answer was just to add eval like so:

eval "parallel julia ~/PATH/TO/FILE/bash-test.jl ::: {$my_var..100..1}"

Inspired by How can I use $variable in a shell brace expansion of a sequence?

Not the answer you're looking for? Browse other questions tagged or ask your own question.