Answer the question
In order to leave comments, you need to log in
Why is the result of executing a command from the terminal and from python different?
There is an Apache 2 server, a flask web application is deployed on it using mod_wsgi (user u1). The system has a user u2 running a tmux session. If you call a bash script from under flask (python subprocess module) with the content, sudo -u u2 tmux ls
then the result of execution will be the output no server running on /tmp/tmux-1001/default . If you call the same script from under ssh (same user u1) the result will be the correct output u2: 1 windows . What could be the reason for this behaviour?
Answer the question
In order to leave comments, you need to log in
the reason may be, for example, the absence of environment variables. try sudo -l -u u2 tmux ls
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question