Gimp-Forum.net

Full Version: Working command line arguments fail in shell script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
After some great help from this forum I've nailed down my Gimp plugins and bash shell commands. However I want to launch them from a shell script and they're failing from there. 

I'm on OS X Mojave. 

Here's my bash shell command:

Code:
gimp -idf --batch-interpreter python-fu-eval -b "import sys;sys.path=['.']+sys.path;import OAFE_PARAM;OAFE_PARAM.open_add_flatten_export('/Users/TimB/Desktop/xcftemplate.xcf', '/Users/TimB/Desktop/jpg_to_add.jpg', 2060, 410, '/Users/TimB/Desktop/')" -b "pdb.gimp_quit(1)"

OS X shell scripts don't recognize my Gimp alias, so I try to launch this and it fails. 

Code:
/applications/GIMP-2.10.app/contents//macos/gimp -idf --batch-interpreter python-fu-eval -b "import sys;sys.path=['.']+sys.path;import OAFE_PARAM;OAFE_PARAM.open_add_flatten_export('/Users/TimB/Desktop/xcftemplate.xcf', '/Users/TimB/Desktop/jpg_to_add.jpg', 2060, 410, '/Users/TimB/Desktop/')" -b "pdb.gimp_quit(1)"

Here's the error I see:

Code:
GIMP is started as MacOS application
2021-03-20 23:44:41.568 gimp[68881:966437] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
/applications/GIMP-2.10.app/contents/macos/gimp: LibGimpBase-WARNING: gimp: gimp_wire_read(): error
GIMP-Warning: The batch interpreter 'python-fu-eval' is not available. Batch mode disabled.

gimp_check_updates_callback: loading of https://www.gimp.org/gimp_versions.json failed: Operation not supported

Any thoughts on what I could do differently?

Starting with "open" at the beginning doesn't work because then it treats my command line parameters as parameters for "open" and not for Gimp.
Your desktop could be starting Gimp using a "facade" script/executable that does some envrionement setup.

In a shell if you enter "python" or "python2", does it start Python? Otherwise where is the Python executable on your system? Was it installed with Gimp?
(03-21-2021, 09:37 AM)Ofnuts Wrote: [ -> ]Your desktop could be starting Gimp using a "facade" script/executable that does some envrionement setup.

In a shell if you enter "python" or "python2", does it start Python? Otherwise where is the Python executable on your system? Was it installed with Gimp?

Natively Python 2.7.16 is installed with OS X. If I type "python --version" that's what I am told. However, I installed a more recent version with HomeBrew, so if I type "python3 --version" it tells me 3.9.1.

Your facade comment makes sense. If I just launch "/applications/GIMP-2.10.app/contents/macos/gimp" from a shell script this is what I see with broken images and stuff:

https://imgur.com/a/D1gdzAP

Using my original script above, I get the same response if I call "/applications/GIMP-2.10.app/contents/mac/os/gimp-console-2.10"

As a test I tried moving my shell script to the same folder where the Gimp executable is stored and it behaves the same way.
On my Linux, the thing that handles -b "python-fu-eval" is /usr/lib/gimp/2.0/plug-ins/python-eval/python-eval.py, so:

  1. The pluginrc file in your Gimp profile should have a line like (plug-in-def "${gimp_plug_in_dir}/plug-ins/python-eval/python-eval.py" 1573315502
  2. The registration atom in the python file should be python-fu-eval
(03-21-2021, 05:59 PM)Ofnuts Wrote: [ -> ]On my Linux, the thing that handles -b "python-fu-eval" is /usr/lib/gimp/2.0/plug-ins/python-eval/python-eval.py, so:

  1. The pluginrc file in your Gimp profile should have a line like (plug-in-def "${gimp_plug_in_dir}/plug-ins/python-eval/python-eval.py" 1573315502
  2. The registration atom in the python file should be python-fu-eval

My pluginrc file is saved here "/Users/TimB/library/application support/gimp/2.10" and it includes something very similar to what you describe above, but with a different number (see below). If I properly understand the meaning of "registration atom" then I believe this also has a registration atom of "python-fu-eval."

If I do this in Linux it works fine to launch Gimp from a shell script, but not in OS X. Any ideas?

Code:
(plug-in-def "${gimp_plug_in_dir}/plug-ins/python-eval.py" 1611605883
   (proc-def "python-fu-eval" 1
        "Evaluate Python code"
        "Evaluate python code under the python interpreter (primarily for batch mode)"
        "Manish Singh"
        "Manish Singh"
        "2006"
        ""
        0
       (icon icon-name -1 "")
        ""
        2 0
       (proc-arg 0 "run-mode" "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }")
       (proc-arg 4 "code" "The code to evaluate")))
The big number is the file time stamp of the executable in Unix time (seconds since 1970-01-01 00:00:00 UTC). Your timestamp indicates you installed Gimp around Jan 25th, 2021.

What is your Gimp alias exactly?
(03-23-2021, 12:46 AM)Ofnuts Wrote: [ -> ]The big number is the file time stamp of the executable in Unix time (seconds since 1970-01-01 00:00:00 UTC). Your timestamp indicates you installed Gimp around Jan 25th, 2021.

What is your Gimp alias exactly?

alias gimp="/Applications/GIMP-2.10.app/Contents/MacOS/gimp"

I have it stored in a file called ".bash_profile" in the folder /Users/TimB
(03-23-2021, 02:36 AM)TimorousMe Wrote: [ -> ]
(03-23-2021, 12:46 AM)Ofnuts Wrote: [ -> ]The big number is the file time stamp of the executable in Unix time (seconds since 1970-01-01 00:00:00 UTC). Your timestamp indicates you installed Gimp around Jan 25th, 2021.

What is your Gimp alias exactly?

alias gimp="/Applications/GIMP-2.10.app/Contents/MacOS/gimp"

I have it stored in a file called ".bash_profile" in the folder /Users/TimB

To clarify though, I don't rely on the alias when using my shell script, because the shell script does not run the alias. Instead I directly run the executable that the alias points to. I only use the alias at the command line (outside of the shell script).
(03-23-2021, 03:19 PM)TimorousMe Wrote: [ -> ]
(03-23-2021, 02:36 AM)TimorousMe Wrote: [ -> ]
(03-23-2021, 12:46 AM)Ofnuts Wrote: [ -> ]The big number is the file time stamp of the executable in Unix time (seconds since 1970-01-01 00:00:00 UTC). Your timestamp indicates you installed Gimp around Jan 25th, 2021.

What is your Gimp alias exactly?

alias gimp="/Applications/GIMP-2.10.app/Contents/MacOS/gimp"

I have it stored in a file called ".bash_profile" in the folder /Users/TimB

To clarify though, I don't rely on the alias when using my shell script, because the shell script does not run the alias. Instead I directly run the executable that the alias points to. I only use the alias at the command line (outside of the shell script).

This article seems to outline a potential solution, but I don't understand what they mean by editing the file "/Applications/GIMP-2.10.app/Contents/MacOS/gimp". If I try to do that I get a bunch of jumbled text as if I'm trying to edit object code or something. Any idea what they are referring to?

https://gitlab.gnome.org/GNOME/gimp/-/issues/3303
(03-24-2021, 04:44 PM)TimorousMe Wrote: [ -> ]
(03-23-2021, 03:19 PM)TimorousMe Wrote: [ -> ]
(03-23-2021, 02:36 AM)TimorousMe Wrote: [ -> ]alias gimp="/Applications/GIMP-2.10.app/Contents/MacOS/gimp"

I have it stored in a file called ".bash_profile" in the folder /Users/TimB

To clarify though, I don't rely on the alias when using my shell script, because the shell script does not run the alias. Instead I directly run the executable that the alias points to. I only use the alias at the command line (outside of the shell script).

This article seems to outline a potential solution, but I don't understand what they mean by editing the file "/Applications/GIMP-2.10.app/Contents/MacOS/gimp". If I try to do that I get a bunch of jumbled text as if I'm trying to edit object code or something. Any idea what they are referring to?

https://gitlab.gnome.org/GNOME/gimp/-/issues/3303

Interesting... From what I infer from that report, on OSX the gimp command appears to be a script that starts a gimp-bin binary. But you seem to have a different setup. Are you using the "official" OSX build or a 3rd party one (in which case asking that 3rd party would be the best course of action)?
Pages: 1 2