To exchange parameters between Bash and Processing you can write the variable into a text file with echo
echo $GRIDTYPE > $TMP/gridsize.i
and later on you read the text file with Processing.
howmanyframes = int(loadStrings("tmp/gridsize.i")[0]);