0

I want to execute my python file in a remote system using ssh. I exported the file to the remote system.

Here's the sample file:

import os
import time
import pymsgbox

pymsgbox.alert('Hi Afreeth ', 'Welcome')
if 'DISPLAY' not in os.environ: 
    pass

I want to execute it using ssh from my system and it should display in the remote system. But it fails

Error i got:

Traceback (most recent call last):
  File "cd1.py", line 5, in <module>
  File "pymsgbox/__init__.py", line 100, in alert
  File "pymsgbox/__init__.py", line 156, in _buttonbox
  File "tkinter/__init__.py", line 1871, in __init__
_tkinter.TclError: no display name and no $DISPLAY environment variable
[12113] Failed to execute script myprogram

How to fix it. I found some answers on stack but it doesn't solve me. If i go and execute it in the remote system, it works. But when i execute from my system,it fails. How to fix it.

2 Answers 2

2

Found the Answer: I just need to run export DISPLAY=:0 in their ssh session and programs run will run on the remote display. A quick example:

paulsteven@smackcoders:~$ ssh afreeth@his_ipaddress
afreeth@smackcoders:~$ export DISPLAY=:0
afreeth@smackcoders:~$ firefox
Firefox is now running on afreeth's display.
Sign up to request clarification or add additional context in comments.

Comments

0

you can use it with python instead of shell

import os

if os.environ.get('DISPLAY','') == '':
    print('no display found. Using :0.0')
    os.environ.__setitem__('DISPLAY', ':0.0')

Note based the display is :0 to make sure on GUI run on GUI terminal echo $DISPLAY
source

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.