'Bash script to connect to wifi using xdotool hangs after invoking firefox

I'm working on a bash script to connect to wifi using xdotool. It works until the script invokes firefox.

Following error is logged after Firefox is invoked:

/home/me/scripts/library_wifi.sh: line 8: $'\E[2K\rDevice': command not found


library=$(nmcli d wifi connect Library_WiFi password XXXXXX)
login_button=$(xdotool mousemove 486 163 click 1)
gateway_library=$(xdotool mousemove 746 417 click 1;sleep 1; xdotool mousemove 1002 512 click 1)

sleep 5


This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source