Page 1 of 1
Adding Bash script as associated program not working
Posted: Mon Jun 02, 2025 10:47 pm
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?
Re: Adding Bash script as associated program not working
Posted: Tue Jun 03, 2025 9:15 pm
by laurent45654
Anybody?
Re: Adding Bash script as associated program not working
Posted: Tue Jun 03, 2025 9:50 pm
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:
- "$@" 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.
Re: Adding Bash script as associated program not working
Posted: Wed Jun 04, 2025 7:29 am
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