So basically I am trying to send commands to my csgo server when I press a button so I can manage easily from anywhere. When I press a button the folowing block of php code is run:
if (isset($_POST['test']))
{
echo shell_exec("tmux send-keys -t ze \"sv_cheats\" ENTER 2>&1");
}
my tmux session gets no input from it and
the echo says that there is no server running on /tmp/tmux-33/default
What I think is happening is my apache server is making its own tmux directory of some sort because this file path exists: /tmp/systemd-private-cf2b583fac384d89981b15c753c6b8bb-apache2.service-jpCxqB/tmp/tmux-33
and thats where its looking.
Im fairly certain that where it needs to be is /tmp/tmux-1001
(which has a file called "default" in it), the only problem Is I have no idea how to make that happen.
You can change the socket tmux talks to with -S
or by setting TMUX_TMPDIR
, for example tmux -S/tmp/tmux-1001/default send-keys ...
.
However, it seems like it is running as UID 33 so it won't be able to talk to your tmux server (which is UID 1001) unless you give it permissions on the socket. Note that any user with access to your tmux socket has full access to your user account, so it would be unwise to share it with the same UID as an Internet-facing server process.
A better way to do this might be to make the PHP code create a temporary file that both users can read (it would need to be a world writable directory or - better - one owned by a shared group), and then have something run as your user that checks that file and does what you want (even if it is as simple as something like while :; do [ -f /tmp/csgo/mybutton ] && (rm /tmp/csgo/mybutton; tmux send-keys ...); sleep 1; done
in a second tmux window).