You are not logged in.

#1 2020-05-30 20:42:12

n00r
Member
Registered: 2017-11-18
Posts: 4

[Solved] Desktop entry for a bash script running a rsync command

Hi there,

I have a bash script that run a rsync command
when I run the script from terminal (gnome) it works fine:

sh ./rsync

Now I create a desktop entry (as I already done for many other scripts) but when I double-click it I got the error:

There was an error launching the application

The desktop entry:

[Desktop Entry]
Version=1.0
Name=Rsync
Comment=Rsync backup script
Exec=/opt/n00r/rsync/rsync
Icon=rsync
Terminal=true
Type=Application
Categories=0Scripts

The bash script :

#!/bin/sh

rsync -aR --relative --stats --protect-args --delete-after $(cat /home/n00r/Scripts/rsync/dirs_list) /run/media/n00r/Backup/arch-backup >> /home/n00r/Scripts/rsync/log.log

One more strange thing is the desktop entry don't appear in the menu. But if I change the exec command to open the file in sublime it works and the icon is shown in the menu

[Desktop Entry]
...
Exec=subl /opt/n00r/rsync/rsync
...

I think my desktop entry file is ok, the script is ok too but something goes wrong with executing a rsync command in bash from a desktop entry

Ps: the script is placed in opt folder as all my other script

I have spent all my day trying to fix it and now I'm giving up and hope someone cant help me

Thanks

Last edited by n00r (2020-05-30 21:12:48)

Offline

#2 2020-05-30 20:49:36

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [Solved] Desktop entry for a bash script running a rsync command

Why would you give the script the same name as the binary?

# edit: paste the output of `printf "%s\n" "$PATH"`

Last edited by jasonwryan (2020-05-30 20:54:01)


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2020-05-30 20:59:26

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: [Solved] Desktop entry for a bash script running a rsync command

You say you run it as `sh ./rsync` but in the desktop file you try to execute the script directly.  This would not be at all surprising if the script was not executable.  Can you run the script directly from the command line?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2020-05-30 21:01:33

n00r
Member
Registered: 2017-11-18
Posts: 4

Re: [Solved] Desktop entry for a bash script running a rsync command

jasonwryan wrote:

Why would you give the script the same name as the binary?

# edit: paste the output of `printf "%s\n" "$PATH"`

Thank you for the replay

excuse me by binary you mean the desktop file ?

the output of `printf "%s\n" "$PATH"`:

/home/n00r/home/n00r/dart-sass:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl

Offline

#5 2020-05-30 21:06:34

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [Solved] Desktop entry for a bash script running a rsync command

So /opt/n00r/rsync/rsync isn't in your path, and the file is not executable...

Don't name your scripts after the binary they call, it can lead to collisions and abherrant behaviour.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#6 2020-05-30 21:08:58

n00r
Member
Registered: 2017-11-18
Posts: 4

Re: [Solved] Desktop entry for a bash script running a rsync command

Trilby wrote:

You say you run it as `sh ./rsync` but in the desktop file you try to execute the script directly.  This would not be at all surprising if the script was not executable.  Can you run the script directly from the command line?

wow thank you Trilby, you are right the script wasn't executable that's why
so many hours lost for an idiot thing

Thank you again and to jasonwryan too

Offline

Board footer

Powered by FluxBB