Y
Y
Yaroslav Belash2019-10-12 21:20:12
linux
Yaroslav Belash, 2019-10-12 21:20:12

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 lsthen 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

2 answer(s)
V
vreitech, 2019-10-12
@fzfx

the reason may be, for example, the absence of environment variables. try sudo -l -u u2 tmux ls.

V
Vitaly Karasik, 2019-10-13
@vitaly_il1

I mean u1, correct
sudo -uu 1 tmux ls

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question