shell script to cd into the /storage/.kodi directory

  • I am trying the cd into /storage/.kodi/userdata to run a python app. I can do it with a cli command.

    cd /storage/.kodi/userdata

    fails with a no such directory error.

    what do I need to do?


    I can cd and execute the python script using a ssh cli just will not work with a shell script that I want to run with cron. If I run the script in the directory the shell script will execute the python script . CD is the problem not python.

  • That is not the problem. I haven't got to the cron part yet. I know how to do that.

    the script is simple

    /opt/zap2/zap.sh:

    #!/bin/bash

    cd /opt/zap2

    python3 zap2epg.py

    I have fixed zap2epg, it runs fine from the directory.

    The script will not do the cd, I have tried source /opt/zap2/zap.sh

    the error is -bash: cd: $'/opt/zap2\r': No such file or directory

    The script was generated on notepad ++ and a try on nano


    If I am in the directory and run the script the python runs.

  • The error is self-explanatory ^ the /opt directory does not exist in LibreELEC and you cannot add it, so you need to modify the script to use some location on the persistent /storage area.

  • 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