In this case the command python
is just a shortcut that is automatically made when you install python. The actual file that runs python has a location just like everything else. The issue is that in linux, not every user has access to the same set of these shortcuts for commands. Your instance of OH is running under a certain user, which depending on your current setup may or may not be the same user as what you see when you open a terminal. If OH is running under a different user: 1) you may in fact have different behaviors between commands that you test in a terminal and commands that are run from OH and 2) instead of just using python
to run your script you may have to use the full path. Nothing else about the command changes, just the form of the python reference:
sudo /usr/bin/python /home/rook/command.py
As Wolfgang_S says, it may be that your only problem is the formatting of the executeCommand
which changed in OH3. But, if you try that correct formatting and it still doesn’t work, then you likely have to use the full path for the python executable:
executeCommandLine("sudo","/usr/bin/python","/home/rook/command.py")