ExpandedVenture / ConnectionSphere

Simple Service to Start Prospecting Online
0 stars 0 forks source link

Can't run xterm terminals on Ubuntu Desktop via SSH, just after reboot server #299

Open leandrosardi opened 2 years ago

leandrosardi commented 2 years ago

I have some servers running Ubuntu Desktop 18.04.

I need to automated this process:

  1. reboot the server.
  2. launch some processes on xterm consoles in the GUI.

Using the GUI is mandatory, because such processes are RPAs running some desktop APPs.

Instead of accessing servers via RDP one by one, and running the processes manually, I want to code some script to do it.

My Script

My script is a Ruby script and it looks like this:

display = host.ssh.exec!("ps -ef |grep Xauthor | grep -v grep | nawk '{print $9}'").strip
s = "DISPLAY=#{display};export DISPLAY;/bin/bash --login -c \"xterm -e bash -c 'cd /home/bots/code/tempora;./shm.rb;bash'\" >/dev/null 2>&1 &"

The Problem

The script above works fine if I previously accessed the server via RDP.

But If I run the script just after rebooted the server, it doesn't work.

I researched a bit, and I noticed that I can't get the display value if I didn't accessed the server via RDP previously. Here is the proof: image

I tried to run the command xhost +, but I am getting this error message: xhost: unable to open display "" image

Additional Notes

This issue is related with #295.

leandrosardi commented 2 years ago

I posted a question in StackOverflow: https://stackoverflow.com/questions/72265226/cant-run-xterm-terminals-on-ubuntu-desktop-via-ssh-just-after-reboot-server