I do not think this is happening. Can you try running this:
cnt=0 for a in 1 2; do for b in 1 2; do echo --- $cnt ssh somehost "echo result: '$cnt'" & let cnt++ done done
Replace somehost with some host where sshd works for you. This prints the numbers 0 - 3, returned from echo result: '$cnt' , executed remotely. Thus, self-execution is working fine.
One thing I can offer is to move your command ( matlab ... ) to some script in a known folder, and then run this script in the above loops, specifying the full path to this script. Sort of:
ssh $NOTE "/path/to/script.sh $cnt"
In the script, $1 you will get the desired value (i.e. $cnt from the loop). You can use echo $1 >> /tmp/values at the beginning of your script to collect all the values ββin the /tmp/values file. Of course rm /tmp/values before you start. This will confirm whether you are getting all the values ββyou want.
source share