I have an array in bash:
ar[0]=1
ar[1]=2
ar[2]=3
echo ${ar[@]}
>1 2 3
export ar
export arTest="test"
and I would like to read in python. But nothing I tried worked:
print os.environ['arTest'] => test
print os.environ['ar'] => raise KeyError(key)
print os.environ['ar[1]'] => raise KeyError(key)
How can I read in the content of the bash array ar
or ${ar[@]}
into Python?
Thx
PS. In fact it seems that Tom's comment is the answer to that question.
It is not a duplication of Exporting an array in bash script as export ar=(1 2 3 4)
has not effect on the result.