How to start an app in a remote desktop












1














I have a GUI app that I can run from a terminal window on a Raspberry Pi desktop and it displays the GUI output on the screen attached to the HDMI port. In the terminal window I run a command like python myapp.py



If at the same time I am logged in to another computer with an ssh terminal back to the RPi, if I run python myapp.py it fails because it can't connect to the display.



I imagine that it must be possible to do this, and perhaps the python myapp.py needs to be wrapped in a script that supplies appropriate environment variables.



What's the best way to solve this?










share|improve this question
























  • If your "other computer" runs an X-Windows server (default if using Linux with a GUI) then you can use X-forwarding (-X option in the ssh command).
    – xenoid
    Dec 25 '18 at 10:26






  • 1




    Welcome to Unix & Linux Stack Exchange.  It would appear that you have accidentally created two accounts. This will interfere with commenting, editing your own posts, and accepting an answer. You should use the contact form and select “I need to merge user profiles” to have your accounts merged.  In order to merge them, you will need to provide links to the two accounts.  For your information, these are unix.stackexchange.com/users/328379/patrick-h (Patrick H) and unix.stackexchange.com/users/328428/padraig-h (Padraig H). You’ll then be able to edit your question.
    – G-Man
    Dec 26 '18 at 2:08
















1














I have a GUI app that I can run from a terminal window on a Raspberry Pi desktop and it displays the GUI output on the screen attached to the HDMI port. In the terminal window I run a command like python myapp.py



If at the same time I am logged in to another computer with an ssh terminal back to the RPi, if I run python myapp.py it fails because it can't connect to the display.



I imagine that it must be possible to do this, and perhaps the python myapp.py needs to be wrapped in a script that supplies appropriate environment variables.



What's the best way to solve this?










share|improve this question
























  • If your "other computer" runs an X-Windows server (default if using Linux with a GUI) then you can use X-forwarding (-X option in the ssh command).
    – xenoid
    Dec 25 '18 at 10:26






  • 1




    Welcome to Unix & Linux Stack Exchange.  It would appear that you have accidentally created two accounts. This will interfere with commenting, editing your own posts, and accepting an answer. You should use the contact form and select “I need to merge user profiles” to have your accounts merged.  In order to merge them, you will need to provide links to the two accounts.  For your information, these are unix.stackexchange.com/users/328379/patrick-h (Patrick H) and unix.stackexchange.com/users/328428/padraig-h (Padraig H). You’ll then be able to edit your question.
    – G-Man
    Dec 26 '18 at 2:08














1












1








1







I have a GUI app that I can run from a terminal window on a Raspberry Pi desktop and it displays the GUI output on the screen attached to the HDMI port. In the terminal window I run a command like python myapp.py



If at the same time I am logged in to another computer with an ssh terminal back to the RPi, if I run python myapp.py it fails because it can't connect to the display.



I imagine that it must be possible to do this, and perhaps the python myapp.py needs to be wrapped in a script that supplies appropriate environment variables.



What's the best way to solve this?










share|improve this question















I have a GUI app that I can run from a terminal window on a Raspberry Pi desktop and it displays the GUI output on the screen attached to the HDMI port. In the terminal window I run a command like python myapp.py



If at the same time I am logged in to another computer with an ssh terminal back to the RPi, if I run python myapp.py it fails because it can't connect to the display.



I imagine that it must be possible to do this, and perhaps the python myapp.py needs to be wrapped in a script that supplies appropriate environment variables.



What's the best way to solve this?







linux shell raspberry-pi console






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 25 '18 at 9:21









P_Yadav

1,5193923




1,5193923










asked Dec 25 '18 at 6:01









Patrick H

61




61












  • If your "other computer" runs an X-Windows server (default if using Linux with a GUI) then you can use X-forwarding (-X option in the ssh command).
    – xenoid
    Dec 25 '18 at 10:26






  • 1




    Welcome to Unix & Linux Stack Exchange.  It would appear that you have accidentally created two accounts. This will interfere with commenting, editing your own posts, and accepting an answer. You should use the contact form and select “I need to merge user profiles” to have your accounts merged.  In order to merge them, you will need to provide links to the two accounts.  For your information, these are unix.stackexchange.com/users/328379/patrick-h (Patrick H) and unix.stackexchange.com/users/328428/padraig-h (Padraig H). You’ll then be able to edit your question.
    – G-Man
    Dec 26 '18 at 2:08


















  • If your "other computer" runs an X-Windows server (default if using Linux with a GUI) then you can use X-forwarding (-X option in the ssh command).
    – xenoid
    Dec 25 '18 at 10:26






  • 1




    Welcome to Unix & Linux Stack Exchange.  It would appear that you have accidentally created two accounts. This will interfere with commenting, editing your own posts, and accepting an answer. You should use the contact form and select “I need to merge user profiles” to have your accounts merged.  In order to merge them, you will need to provide links to the two accounts.  For your information, these are unix.stackexchange.com/users/328379/patrick-h (Patrick H) and unix.stackexchange.com/users/328428/padraig-h (Padraig H). You’ll then be able to edit your question.
    – G-Man
    Dec 26 '18 at 2:08
















If your "other computer" runs an X-Windows server (default if using Linux with a GUI) then you can use X-forwarding (-X option in the ssh command).
– xenoid
Dec 25 '18 at 10:26




If your "other computer" runs an X-Windows server (default if using Linux with a GUI) then you can use X-forwarding (-X option in the ssh command).
– xenoid
Dec 25 '18 at 10:26




1




1




Welcome to Unix & Linux Stack Exchange.  It would appear that you have accidentally created two accounts. This will interfere with commenting, editing your own posts, and accepting an answer. You should use the contact form and select “I need to merge user profiles” to have your accounts merged.  In order to merge them, you will need to provide links to the two accounts.  For your information, these are unix.stackexchange.com/users/328379/patrick-h (Patrick H) and unix.stackexchange.com/users/328428/padraig-h (Padraig H). You’ll then be able to edit your question.
– G-Man
Dec 26 '18 at 2:08




Welcome to Unix & Linux Stack Exchange.  It would appear that you have accidentally created two accounts. This will interfere with commenting, editing your own posts, and accepting an answer. You should use the contact form and select “I need to merge user profiles” to have your accounts merged.  In order to merge them, you will need to provide links to the two accounts.  For your information, these are unix.stackexchange.com/users/328379/patrick-h (Patrick H) and unix.stackexchange.com/users/328428/padraig-h (Padraig H). You’ll then be able to edit your question.
– G-Man
Dec 26 '18 at 2:08










3 Answers
3






active

oldest

votes


















1














As mentioned in comments, assuming the remote machine is running X Window Server, you can redirect the display to this machine using -X:



From man page:




-X Enables X11 forwarding.




So from remote host:



ssh user@raspberry -X


Then simply run your app:



python myapp.py





share|improve this answer





















  • In response to Kevin... I tried doing 'ssh -X me@RPi as suggested, and then ran the 'python myapp.py' command, but I get an error: pygame.error: Unable to open a console terminal
    – Padraig H
    Dec 25 '18 at 17:14



















1














You need to start an X server on your Raspberry Pi, then just type in DISPLAY=:0 python myapp.py into your SSH session. It should start.






share|improve this answer





























    -2














    Success!



    Interestingly, it was not necessary to use the -X argument...



    From the remote system:



    ssh RPi


    Then do:



    DISPLAY=:0 python myapp.py


    Thanks to both responders!






    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "106"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f490842%2fhow-to-start-an-app-in-a-remote-desktop%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      As mentioned in comments, assuming the remote machine is running X Window Server, you can redirect the display to this machine using -X:



      From man page:




      -X Enables X11 forwarding.




      So from remote host:



      ssh user@raspberry -X


      Then simply run your app:



      python myapp.py





      share|improve this answer





















      • In response to Kevin... I tried doing 'ssh -X me@RPi as suggested, and then ran the 'python myapp.py' command, but I get an error: pygame.error: Unable to open a console terminal
        – Padraig H
        Dec 25 '18 at 17:14
















      1














      As mentioned in comments, assuming the remote machine is running X Window Server, you can redirect the display to this machine using -X:



      From man page:




      -X Enables X11 forwarding.




      So from remote host:



      ssh user@raspberry -X


      Then simply run your app:



      python myapp.py





      share|improve this answer





















      • In response to Kevin... I tried doing 'ssh -X me@RPi as suggested, and then ran the 'python myapp.py' command, but I get an error: pygame.error: Unable to open a console terminal
        – Padraig H
        Dec 25 '18 at 17:14














      1












      1








      1






      As mentioned in comments, assuming the remote machine is running X Window Server, you can redirect the display to this machine using -X:



      From man page:




      -X Enables X11 forwarding.




      So from remote host:



      ssh user@raspberry -X


      Then simply run your app:



      python myapp.py





      share|improve this answer












      As mentioned in comments, assuming the remote machine is running X Window Server, you can redirect the display to this machine using -X:



      From man page:




      -X Enables X11 forwarding.




      So from remote host:



      ssh user@raspberry -X


      Then simply run your app:



      python myapp.py






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Dec 25 '18 at 10:40









      Kevin Lemaire

      1,160624




      1,160624












      • In response to Kevin... I tried doing 'ssh -X me@RPi as suggested, and then ran the 'python myapp.py' command, but I get an error: pygame.error: Unable to open a console terminal
        – Padraig H
        Dec 25 '18 at 17:14


















      • In response to Kevin... I tried doing 'ssh -X me@RPi as suggested, and then ran the 'python myapp.py' command, but I get an error: pygame.error: Unable to open a console terminal
        – Padraig H
        Dec 25 '18 at 17:14
















      In response to Kevin... I tried doing 'ssh -X me@RPi as suggested, and then ran the 'python myapp.py' command, but I get an error: pygame.error: Unable to open a console terminal
      – Padraig H
      Dec 25 '18 at 17:14




      In response to Kevin... I tried doing 'ssh -X me@RPi as suggested, and then ran the 'python myapp.py' command, but I get an error: pygame.error: Unable to open a console terminal
      – Padraig H
      Dec 25 '18 at 17:14













      1














      You need to start an X server on your Raspberry Pi, then just type in DISPLAY=:0 python myapp.py into your SSH session. It should start.






      share|improve this answer


























        1














        You need to start an X server on your Raspberry Pi, then just type in DISPLAY=:0 python myapp.py into your SSH session. It should start.






        share|improve this answer
























          1












          1








          1






          You need to start an X server on your Raspberry Pi, then just type in DISPLAY=:0 python myapp.py into your SSH session. It should start.






          share|improve this answer












          You need to start an X server on your Raspberry Pi, then just type in DISPLAY=:0 python myapp.py into your SSH session. It should start.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 25 '18 at 10:41









          Михайло Оришич

          113




          113























              -2














              Success!



              Interestingly, it was not necessary to use the -X argument...



              From the remote system:



              ssh RPi


              Then do:



              DISPLAY=:0 python myapp.py


              Thanks to both responders!






              share|improve this answer




























                -2














                Success!



                Interestingly, it was not necessary to use the -X argument...



                From the remote system:



                ssh RPi


                Then do:



                DISPLAY=:0 python myapp.py


                Thanks to both responders!






                share|improve this answer


























                  -2












                  -2








                  -2






                  Success!



                  Interestingly, it was not necessary to use the -X argument...



                  From the remote system:



                  ssh RPi


                  Then do:



                  DISPLAY=:0 python myapp.py


                  Thanks to both responders!






                  share|improve this answer














                  Success!



                  Interestingly, it was not necessary to use the -X argument...



                  From the remote system:



                  ssh RPi


                  Then do:



                  DISPLAY=:0 python myapp.py


                  Thanks to both responders!







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Dec 26 '18 at 4:45









                  Jeff Schaller

                  39k1053125




                  39k1053125










                  answered Dec 25 '18 at 17:20









                  Padraig H

                  11




                  11






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f490842%2fhow-to-start-an-app-in-a-remote-desktop%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Morgemoulin

                      Scott Moir

                      Souastre