0

I have an Ubuntu 20.04 Linux setup, with xfce, xorg and xrdp installed. My objective is to run an application inside a graphics environment, do some clicks, monitor its performance, and them close it after some time.

I am able to do it using an RDP session, by running "app.sh" in the terminal on the remote machine. But I would like this process to be more automated, and the app to start using remote ssh, whithout having to do the RDP session. Unfortunately I am not familiar enough with linux to know where to start.

What have I attempted so far:

  1. Just running "app.sh" from a remote ssh results in "Could not detect graphics environment" error.
  2. Using "xinit app.sh 'displayconfig'" command. The app seems to run but the app ui does not seem to initialize on the remote machine (or at least I cannot detect it)

For my purposes, I do not care whether or not a display session or rdp session is active (please correct me if I got the terminology wrong). My only objective is to start the app on the remote machine, send a click event to some (X,Y) coords, and then close the app. I do not want to actually see the actual UI.

Edit 1: Expected behavior (for clarity):

  1. I connect to the remote machine though ssh
  2. I run some command to start the app on the remote server
  3. The app starts on the remote server (with the ui and everithing)
  4. I dont see the UI on the local machine, but it is running on remote
  5. I send a click event to some (X,Y) coords (I have a python script for that)
  6. I monitor the performance of the app (the cloud setup does that for me)
  7. I close the app after some time
  8. I close the ssh connection

May be relevant: My app is a Java Swing based app, and I am using JVMTI to detect the UI

Edit 2: I will try to explain my setup a bit more, as the answers provided make the wrong assumptions:

I have 2 linux servers: server A and server B. server A acts as a repository (no graphics or anything) where different versions of the same app are uploaded. Once a new version for my app is uploaded, Server A uploaded that version to Server B, and deletes the old version (this part I have figured out). Now server B has some graphics installed. I need Server A to send some command to Server B to start the app as if it was a user (human) using the GUI. Now server A does not have any display, so I cannot forward the gui anywhere. So far, I have an 'app.sh' file with which managed to start the app, using RDP (from a windows machine) to connect. This, unfortunately, is not an option for production. What I need is some way to start a graphics environment on server B from server A and run the app there, or just have some 'always on' session which has a graphics environment on server B, and somehow start my app from server A with that session. I do not actually need the visual feed of the gui, as I dont need to see it, nor will I have any physical display for it, it can be purely virtual/simulated on server B, or it can be missing at all if there is a way to "click a button" without it.

Screenshots (redacted for confidentiality):

  1. App running with RDP session What you can see: Open RDP session, App running in background (behind terminal, not as background process), Terminal 2 started the app by calling 'app.sh', Terminal 1 sent a 'list ui' command to the app. All works fine

  2. SSH connection, attempting same commands as previously (remember, no PHISICAL display / no desktop screen available in production

What can you see: an open SSH connection, attempting to call same 'app.sh' as before.

More info: running 'echo $XDG_CURRENT_DESKTOP':

  1. in RDP session: > 'XFCE'
  2. in SSH session: > ''

Would something like this be possible? Please dont hesitate to request additional info

Petru Tanas
  • 111
  • 6

2 Answers2

1

Start ssh with: ssh -Y user_id@host.com and provide login credentials. Start X11 software with it's command, for example xclock (one might use & to preserve prompt). To start program in Windows 10/11 environment most recommendable is WSL2 with it's GUI support. Other option for Windows is Xming (https://sourceforge.net/projects/xming/). On Linux systems just ssh with -Y and start program. One has to enable X11 forwarding in target machine (where you start the program) in the /etc/ssh/sshd_config file by removing # in X11Forwarding yes (if no change to yes). Good practice is also enable forwarding in client (/etc/ssh/ssh_config) ForwardX11 yes. Remember to restart ssh by sudo systemctl restart ssh.

0

From your comment,

I dont want to see the ui locally. It can appear on the remote machine if it needs to, I just dont want to see it. I want a script which will start "in the background" in some sense, without opening any UI on my local machine and then write the result to a file. If the UI is actually running on the remote machine thats fine.

It sounds like you want command-line control over software running on a remote machine, which has been used exclusively with GUI until this point, so that you can automate some task with that software. You want to execute commands on a remote machine, and receive the output.

It's impossible to know what the CLI commands are for that software without knowing what the software is, but the general structure would be this:

ssh user@remotemachine [command {flags, objects}] > /file/path/to/output/file/output.extension

For example, if I wanted to see the fstab contents on the remote computer at the IP address 123.45.67.890, then I would do the following:

ssh root@123.45.67.890 cat /etc/fstab > /home/me/fstab.txt

For your case, you will need to find the command-line commands for the software you wish to use.