Adding Bash script as associated program not working

Ask for help and post your question on how to use XnView MP.

Moderators: helmut, XnTriq, xnview

Post Reply
laurent45654
Posts: 21
Joined: Sat Dec 21, 2024 6:54 pm

Adding Bash script as associated program not working

Post by laurent45654 »

I've created a simple Bash script that converts the provided file to JPEG and adds a watermark. I've then added it to the Configured Programs - I've set the path to my Bash script and left the Arguments empty.

Now when I try to run this, nothing happens. In the console it only shows this:

Code: Select all

_LSOpenURLsWithCompletionHandler() failed for the application /Users/path/imageToWatermarkedJpeg.sh with error -10811 for the file /path/to/image.png
Any idea what could be the issue?
laurent45654
Posts: 21
Joined: Sat Dec 21, 2024 6:54 pm

Re: Adding Bash script as associated program not working

Post by laurent45654 »

Anybody?
laurent45654
Posts: 21
Joined: Sat Dec 21, 2024 6:54 pm

Re: Adding Bash script as associated program not working

Post by laurent45654 »

Ok I finally found how to do it (on macOS). Putting a mini-tutorial here in case someone ends up here:

First, XnView is not going to run CLI programs, at least as far I can tell. The error indicates that it's trying to open the shell script as if it was an app, or maybe with the default associated program (which may be a text editor) - so basically not doing what you want. So the trick is to convert that script to a GUI app, and that can be done using Automator.

- First open Automator
- Select "Application" as document type
- Add a "Run Shell Script" action
- Set the command to this:

Code: Select all

/path/to/yourscript.sh "$@"
- "$@" is important to ensure the arguments are passed to your script, since Automator won't do it by default
- In the "Pass input" dropdown, select "As arguments" - again so that the file path is passed to your script

Once done save the app. You can now add it from "Configure programs" and it should work.
User avatar
xnview
Author of XnView
Posts: 46235
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Adding Bash script as associated program not working

Post by xnview »

laurent45654 wrote: Tue Jun 03, 2025 9:50 pm The error indicates that it's trying to open the shell script as if it was an app,
yes, standard open from finder is used
Pierre.
Post Reply