This small script reads the file with the local strings and builds a file with commands: export LOCAL491="Success"... At last it changes permissions, and runs the new command file. When returning to main script, The variables are NOT set. Why?
Code: Select all
#!/bin/bash
echo -e "\c" > /tmp/local_codes
echo -e "\c" > /tmp/variables
echo "491=Success" >> /tmp/local_codes
echo "492=Error" >> /tmp/local_codes
for I in `seq 400 500`; do
TMP=`grep $I= /tmp/local_codes | sed -e s/^.*\=//g` #TMP = 'Success' or 'Error'
if [ "$TMP" ]; then
echo "export LOCAL$I="'"'"$TMP"'"' >> /tmp/variables #build command file
fi
done
chmod 777 /tmp/variables; /tmp/variables #run command file
echo "This should echo content of variable LOCAL491: $LOCAL491"