'Executing .sh file at raspberry using paramiko

I have to refresh the chromium page at a raspberrypi remotelly, I managed to run a .py file but the .sh it's not executing.

If I execute on the raspberry itself, the refresh works perfectly.

Here is the code I'm trying:

import paramiko

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=hostname,username=username, password=password)

stdin, stdout, stderr = client.exec_command("bash /home/pi/refresh.sh'")

for line in stdout:
    print (line.strip('\n'))
 
client.close()

Here is the .sh file:

WID=$(xdotool search --onlyvisible --class chromium|head -1)
xdotool windowactivate ${WID}
xdotool key ctrl+F5

Does anyone have any idea of what might be happening?

Thanks in advance



Solution 1:[1]

I managed to solve the problem by adding DISPLAY=:0 on the beginning of the .sh commands, example:

DISPLAY=:0 xdotool key F5

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ddddddd