Python Forum
Strange problem related to "python service" - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Strange problem related to "python service" (/thread-35734.html)



Strange problem related to "python service" - Pavel_47 - Dec-07-2021

Hello,

I faced to a quite strange problem: if my python program is started as service certain commands aren't executed correctly whereas if I start it in python environment the same commands executed correctly.
For example if the following command
bbb = os.popen('ls').read()
is executed in python environment, in bbb variable there is content of current directory
In the case of launching as service the bbb variable is empty.
Any comments ?
Thanks.


RE: Strange problem related to "python service" - Pavel_47 - Dec-07-2021

Resolved.
If program is used as a service, the full path to linux command must be specified, i.e. instead of
bbb = os.popen('ls').read()
do
bbb = os.popen('/bin/ls').read()