0
$(run-parts --list --reverse --regex '^KeePassXC-[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]-x86_64\.AppImage' bin | head -n 1)

(The purpose of the above command is to run the most recent version of KeePassXC found in ~/bin; I don't want to have to modify the startup entry each time I have to upgrade KeePass)

The above command seem to work if run from the terminal. However, if I press Alt+F2 to get the GUI 'run command' box, I'm getting errors:

Failed to execute child process "$(run-parts" (No such file or directory)

Even more importantly, similar problem happens if I try to enter this command to Startup Applications:

Could not execute '$(run-parts --list --reverse --regex '^KeePassXC-[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]-x86_64\.AppImage' bin | head -n 1)'
Failed to execute child process "$(run-parts" (No such file or directory)

I thought that maybe my mistake is that Startup Applications / Run command GUI box run the commands from / rather than ~? So I "fixed" my command, namely I removed bin and replaced it with /home/m/bin BUT this did not help.

Why am I failing to execute this command from any place BUT the terminal?

4
  • 1
    The issue seems to be that the box you're typing this command into is not a shell and can therefor not make sense of you command substitution. What you could do is to change the single quotes to double quotes and then use the command sh -c 'you-original-thing' in the box.
    – Kusalananda
    Commented Dec 21, 2019 at 20:05
  • @Kusalananda Thank you!
    – gaazkam
    Commented Dec 21, 2019 at 20:16
  • Note that my last comment is not a proper answer, just a comment. I have no system where I have such a box available and can't test anything that I said in that comment. It just seemed a reasonable explanation and the "solution" follows from that.
    – Kusalananda
    Commented Dec 21, 2019 at 20:49
  • @Kusalananda But it seems to work on my PC.
    – gaazkam
    Commented Dec 21, 2019 at 20:57

1 Answer 1

3

The error message:

Could not execute '$(run-parts --list --reverse --regex '^KeePassXC-[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]-x86_64\.AppImage' bin | head -n 1)'
Failed to execute child process "$(run-parts" (No such file or directory)

This indicates that the box that you're typing the command into is not a shell, and that it's instead trying to execute the literal command. A shell would have parsed the command, expanded the command substitution, run the pipeline with run-parts and head etc.

Since the box is not a shell, and since the command is not a simple command (a command, possibly with options), you will have to invoke your original command with a shell. You can do that from the GUI box with the command

sh -c 'your command'

where your command is the command that you initially tried to run (with single quotes replaced by double quotes, because the single quoted argument to sh -c can't contain other single quotes).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .