I am able to assign the DISPLAY variable by running the command line:
export DISPLAY=:2
echo $DISPLAY (returns 2)
hostname (returns opt2)
In my #!/bin/bash script using the same command:
echo $DISPLAY (returns 2)
export DISPLAY=:3
echo $DISPLAY (returns 3)
hostname (returns opt2)
BUT, when I do echo $DISPLAY after the script is finished I still get "2" as the DISPLAY variable; in other words, the script failed to reassign the DISPLAY variable from "2" to "3".
If I run my bash script a second (third, fourth....) time, I always get:
echo $DISPLAY (returns 2)
export DISPLAY=:3
echo $DISPLAY (returns 3)
hostname (returns opt2)
So, although the script says it assigned the DISPLAY variable to "3", it does not!
How do I make my bash script assign the DISPLAY variable?
