I forgot to say I was aware of no /opt in LE. The example I gave was on another Ubuntu machine for testing since I was thinking it might be a LE limitation.
On LE I was actually using /storage/,kodi/addon_data/script.module.zap2epg. I had the same result there. For testing sake everything is set to 777.
I did figure out that on LE to cd to /storage/.kodi I had to do cd ~/.kodior cd $HOME/.kodi
I seem to have found the problem: the \r that somehow got in. I thought notepad++ and nano didn't add that.
the new script is after I ran it through dos2unix
#!/bin/bash
# Change directory to /opt/zap2
cd "$HOME/zap2" || { echo "Error: Could not change directory"; exit 1; }
# Execute the Python3 script (assuming it's named zap2_script.py)
python3 zap2epg.py || { echo "Error: Python script failed"; exit 1; }
# Script exits successfully
exit 0