Start window application from ssh - linux

I'm connected to my Raspberry PI via SSH (Rasbian). Now I want to start an Application from it that uses a Graphical Interface. That Application is a simple Mono Window. It should be displayed on the PI's Display
I can't do it because it tells me that is has no DISPLAY set (thats true, since I use SSH)
When I'm starting it from the terminal app on the PI's Desktop it works as expected.
My querstion is now: What do I have to do, that I can start this app over SSH and the window pops up on the PI's desktop?

If you're trying to start the X application on the remote X server, see https://serverfault.com/questions/142244/how-do-i-start-a-x-application-on-remote-server-over-ssh
If you're trying to start the X application on the Pi, but show its window on your local desktop (you'll need X11 on your local desktop), use ssh -X.

Related

Run any kind of browser on Raspberry pi 3 without GUI

The goal is to open a web browser in my home network from a from a remote location with ssh tunnelling.
SSH tunnel is okay, I just want to somehow run a browser on my RPI3 in my home network.
Is it possible somehow?
I use my pi as a media server, only kodi is running on it, there isn't any GUI operating system on it (raspbian for example).
All kind of solution is interested.

Raspberry Pi SSH Not Working

I am trying to SSH into my raspberry pi from my windows machine, and the terminal environment WAS working fine, but the GUI is acting really crappy. There is no Xming window that opens up when Xming starts (but it is running according to the task manager). The taskbar in Raspbian doesn't move around (and covers up the windows taskbar), and there is a bunch of little glitches with the desktop. My motors are also being weird: when I turn on my Pi one of them starts moving. The same thing happens when I turn off my Pi (but not the H-Bridge Board). Everything (including the motors) work perfectly fine when I use my Pi with a TV via HDMI. I have the model 2 Raspberry Pi running Raspbian, Windows 10 on my computer, and am using Putty. I'm pretty new to this, so I will appreciate any help.
Do you need the GUI? If not, I would suggest turning off X11 forwarding in putty (Connection - SSH - X11) and just using the console.

How to attach ttyS to screen and capture it simultaneously

For capturing ssh sessions I use "script" command: "script -c 'ssh user#host' outfile". But I have no idea how to capture sessions to remote hosts, that connected over com(serial) port.
screen script -c 'screen /dev/ttyS0 57600' file
ends immediately with empty log. Both 2 functions that implemented in screen is necessary: ability to switch between opened sessions and ability to perform i/o to /dev/ttyS. I started develop some tiny utility to redirect stdin/stdout to /dev/ttyS but now it's so buggy and doesn't work yet.
First off, a terminal program, like minicom (or good-ol cu), as suggested by Laszlo, is needed to communicate with the remote system. Once you can get such a program to work, then screen can be brought into the picture. Note that this also requires a getty running on the remote computer's serial port. If it's an old-fashioned serial port, you may also need a special null-modem cable.
Screen can be used with such a connection to be able to move access of the session across terminals. However, it cannot be used to spawn more than one session with the remote server. That's because the program running on the serial port (getty) only supports a single session. In this case, the screen runs on the local machine, and the terminal-program session running within screen connects to the remote server. So, it is possible to have multiple screens, but just not more than one connected to the remote server over a single serial port.
With all of that said, serial ports can be used to network two machines, assuming both support the same serial-line networking protocol. Networking eliminates these restrictions.
To open an interactive terminal session to a COM port (/dev/ttyS*), you probably want to use a terminal emulator software, like 'minicom'.

X session, but only remote

I would like to setup a small computer (Raspberry Pi) running Arch Linux to accept remote X sessions. Doing this usually means setting up Xorg server and running one of the Display Managers. I have done this before, and I will go this route if I have to. However, since the machine is very underpowered, and it is actually not connected to a physical monitor, I was hoping to setup the X server to accept only remote sessions. This way no memory would be wasted on managing the local graphics card, video memory etc, since they are not being used. Is it possible to setup the X server to accept only remote sessions without going into local graphical mode? And how?
It's possible to set up a *ix to remote display to a system you're sitting in front of, without an X server on the machine running the app.
You need X11 libraries, one or more X11 applications, and you probably want openssh set up for remote X11 forwarding - all on the raspberry pi. You'll also want an X server running on the machine you're sitting in front of.
On the Raspberry Pi, change your sshd_config to include "X11Forwarding yes". After making this change, restart sshd or reboot.
Then apt-get or yum your X11 libraries and app(s).
When you connect to the Raspberry Pi machine, use "ssh -Y" instead of just ssh to pass along xauth data.
Good luck!
Disable automatic start of the login manager and X server, instructions are googlable, say http://www.debianadmin.com/howto-boot-debian-in-text-mode-instead-of-graphical-mode-gui.html. From personal experience running X apps on raspberry remotely is not too good either.

How to launch firefox from C program/daemon under Linux

I am having some problems with launching firefox from a Linux daemon written in C.
When I launch firefox on the machine itself (via terminal) from the command shell using /usr/bin/firefox it works OK and a firefox browser window lanunches as it should.
However if I try this within my C daemon using system("/usr/bin/firefox"), firefox launches its process in the terminal but the browser window is not opened?
A similar thing happens when I try to do this using remote terminal acces. It's something to do with telling the system to open firefox in window mode rather than trying to open it in terminal mode - but I dont know how to specify this using bash commands?
I am using Lubuntu 11.10 in my Linux System.
Any help is most appreciated.
There's a reason I asked why you're attempting to do what you want. I didn't want to get into great details in my comment.
Firefox on Unix is an X-Window process (most of the Linux/Unix desktops are based upon the X11 protocol which is the heart of X-Window). What X-Window does is separate the display of the program from the process running the program. For example, I am now running Firefox from a Linux box at work, but the Linux box is actually displaying the Firefox browser window at home on my Mac.
In order to do this, I had to:
Run X11 on my Mac. The X11 program creates a default X11 client display called 0.0 which pretty much says the first screen and the first instance of X11 running (computer geeks like counting from zero). The process runs in the background on my Mac. In a certain sense, it's really a server process and not a client because it's waiting on port 6000 for a client X11 process (Firefox) to tell it what to do.
Before I run firefox, I have to tell my Mac's X11 process that I grant the X11 server running Firefox to be able to display on my X11 client process. Otherwise, you can imagine someone spamming another person by continuously popping up Windows on their display. You can use the xhost program to do this.
In order to run Firefox on the Linux box, I have tell the Firefox process what X11 client I'm running it on. I can do this by setting the DISPLAY environment variable to something like "10.0.1.33:0.0". This means the X11 client is running the the machine on IP address 10.0.1.33, and I want you to use the first screen, and the first instance of the X11 client on that screen.
Now, I can run Firefox on my Linux box, and the display will display on my Mac.
The problem you're running into is that there's simply no X11 client when you're starting FireFox as a daemon process. An X11 client is associated with a user and a display of some sort. The display could be a virtual display, but there's got to be an X11 client that's running and is addressable in some way, so the process knows where to display the output.
By the way, you said daemon which has a very, very specific meaning in Unix/Linux. A daemon is a process that runs in the background and usually has a service (and a port) associated with it. For example, there's an FTP daemon called ftpd, the mail server uses the sendmail daemon, ssh has the sshd daemon. Daemons have no display associated with them.
However, it looks like you might be using the word to mean launching Firefox via another process. Is that true? If so, you'll have to make sure that Firefox knows the X11 display to use (there's a command line setting to use to specify the display), and that your X11 client (your login session) has given permission for another process to update your display with the program window.
Can you please explain what you're trying to do in a bit more detail? If you simply want to download a file from a remote http server (which of course is running the http daemon process called httpd), you should use curl or wget which don't require a display and are way simpler to use. If you're trying to do something else, let us know exactly what it is.
Firefox needs to know which display it should open on. When you run it from within a gui, even through a terminal emulator, the DISPLAY environment variable is set to the appropriate value. When you launch from the daemon, try system("/usr/bin/firefox -display=:0").
Make sure that the DISPLAY environment variable is properly set in your daemon to refer to the X server that you want your firefox to use.
If the daemon is run as a different user account than the user account that "owns" the X server that you want to use, you will also need to use xauth(1) to configure the authentication token to grant permission to use the X server.
Often times, it is far easier to use ssh -X to tunnel X and properly configure the xauth(1) tokens in one go than try to manage xauth(1) tokens yourself. Maybe adding ssh -X into your environment would be suitable, maybe not. (I've even used ssh -X root#localhost before when I needed to run an X client as root and didn't want to bother with configuring xauth(1) manually. ssh(1) is just so much easier.)

Resources