1

Basically I am executing this script remotely via an SSH session. It works fine on Linux Mint, but not on Debian (7.5). It looks like the export display or nohup command isn't working, but I'm not sure what to try to test this. Can anyone see anything wrong with this?

#!/usr/bin/env bash
mount -t cifs //10.50.18.114/Presentation -o 'username=Administrator,password=***,sec=ntlm' /mnt/share
pkill soffice.bin
cp -v /mnt/share/Pres.ppt /home/kyle/Documents
chmod 777 /home/kyle/Documents/Pres.ppt
export DISPLAY=":0"
nohup libreoffice --norestore --nolockcheck --show /home/kyle/Documents/Pres.ppt &
sessionid="$(pidof -s sshd)"
kill $sessionid
exit

EDIT: This is not the same issue as shown in the 'duplicate' link provided, I've used the information in that thread and it didn't work.

To answer the comments: I have 2 separate machines. The presentation PC has the above script saved locally. I am executing this script remotely over SSH, I put echo commands in between each stage and it looks as if it executes all the way to the end (I actually commented out the kill sessionid), but the presentation doesn't display on the presentation PC. The script works if I execute locally as root (it needs root to use the mount command).

The only error I see is:

(soffice:3747): GConf-WARNING **: Client failed to connect to the D-BUS daemon: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken. GConf Error: No D-BUS daemon running

However, I get this error whether I run locally or over SSH, so I don't think this is the issue. I still believe it is something with the EXPORT and nohup command, but I don't know enough to troubleshoot effectively.

EDIT 2: It actually works when I SSH with my 'kyle' account, it seems connecting via SSH with root isn't able to connect to 'kyle's local display because it is a different username. I will work on finding a solution to this.

  • What happens when you execute the script ? Do you get an error message ? – lgeorget May 28 '14 at 13:04
  • The X server runs on the same machine as the SSH server? – Felix Frank May 28 '14 at 13:44
  • I don't believe the "duplicate" gives the best answer to this question. Try using the -X option with ssh. That defines a display for the remote session and tunnels it back to your local display. – BobDoolittle May 29 '14 at 0:27
0

If you want to start remotely a program in a graphical session you need to set more than the DISPLAY environment variable. You should set at least XAUTHORITY and DBUS_SESSION_BUS_ADDRESS. Other variables that would be nice to set are the XDG_* ones like XDG_RUNTIME_DIR, XDG_SEAT etc.

You can find out their values by running something like:

PID_OF_SOME_GUI_PROGRAM=`pidof soffice.bin` # before you pkill it
strings /proc/${PID_OF_SOME_GUI_PROGRAM}/environ | grep XAUTHORITY

If you're using XFCE, you can also do:

PID_OF_SOME_GUI_PROGRAM=`pidof xfce4-session`

(For GNOME, it's probably gnome-session)

0

Following my discovery from the information in 'EDIT 2', I have decided to just execute the mount part of the script separately with plink. plink will make 3 different SSH connections to the machine: 1. Automatically accept fingerprint 2. Mount the share as root 3. Run the main script to copy and start the presentation as standard user.

The Windows side plink script looks like this:

echo y | plink -ssh root@192.168.124.137 "exit"
plink -ssh root@192.168.124.137 -pw password /home/kyle/Desktop/mount.sh
plink -ssh kyle@192.168.124.137 -pw kyle /home/kyle/Desktop/restart-pres.sh

This may not be the most effective solution, but it works for my situation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.