On Tue, 28 Jan 2020 11:24:04 -0800 Ben Koenig <techkoe...@gmail.com> dijo:
>> Now the script says '$XAUTHORITY=/home/jjj/.Xauthority gxmessage >> -display :0 "Hello world"' but I get: >> >> /home/jjj/Software/./Backup_script_for_Home.sh: line >> 9: /home/jjj/.Xauthority=/home/jjj/.Xauthority: No such file or >> directory >> >> I checked and the .Xauthority file is really there, and a search >> revealed that there are no other .Xauthority files or folders >> anywhere on ~/. >XAUTHORITY , remove the leading $ from your command. When setting a >shell variable, just use the name. When referring to it, use the $. > >In this case the variable is unset because cron runs independently of >X. So you run the command as follows: >XAUTHORITY=/path/to/file DISPLAY=:0 gxmessage > >It's possible ubuntu puts it somewhere else, it doesn't need to be in >your home folder so log in to your desktop. let's set cron aside for a >second and test our commands to make sure they work. Here are the >commands I used to verify that I have everything lined up: >ben@laptop:~$ echo $XAUTHORITY >/home/ben/.Xauthority >ben@laptop:~$ echo $DISPLAY >See how I take the value returned by echoing the variables and used >them in the gxmessage command? It's an override, the last command can >be run from any terminal as long as you are logged in. Once you know >what the Xauth and DISPLAY variables should be set to, you can alt-f2 >to get out of X, and run any command regardless of where the shell is >to pop up a window. scripts executed from cron will always need this >treatment since they are not inherently aware of X. This changes from >distro to distro, so the paths I have on slackware are simply the >upstream defaults and I would not be surprised if other distros have >their own temp folders for these auth files. I already knew that .Xauthority was in ~/, but I double-confirmed it with the echo command. Then I removed the leading $, and now I get No protocol specified Unable to init server: Could not connect: Connection refused gxmessage: unable to initialize GTK I posted about this on Ubuntu forums and someone suggested that I needed to add 'export DISPLAY=:0' before the rsync command, so I tried it, and then I added 'export XAUTHORITY=/home/jjj/.Xauthority' as well, but I still get the error message as above. Here is the current incarnation of my script: #!/bin/bash export DISPLAY=:0 export XAUTHORITY=/home/jjj/.Xauthority TS=`date` rsync -avx --delete /home/jjj/ /media/jjj/Data/JJJ gxmessage "Hello world" And, as always, if I run the script myself the message always pops up as expected. _______________________________________________ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug