Switch to full style
Ask all general Gimp related questions here
Post a reply

Cannot run test script-fu script via console

Sat Jun 05, 2021 1:18 pm

GIMP Version: 2.10.24
Operating System: Windows
OS Version: Windows 10
GIMP Experience: New User



Hello, I'm having a very unusual problem when experimenting with running a very basic scm script.

I have one version of the script that is this:
Code:
(define (script-fu-test)
(gimp-message "no variable TEST!")
)


When I run this code with the command line prompt
Code:
gimp-2.10.exe -i -b "(script-fu-test)" -b "(gimp-quit 0)" 

it performs as expected, outputting "no variable TEST!" in the GIMP output window, after which it reports that the 'batch command executed succesfully' and then prompts me to press any key to exit. This is all well and good.

However, when I modify the script as such:
Code:
(define (script-fu-test strpass)
(gimp-message "no variable TEST!")
(gimp-message (string-append "TEST! with" strpass))
)

and I input the command line prompt
Code:
gimp-2.10.exe -i -b "(script-fu-test "stringy thingy TEST")" -b "(gimp-quit 0)"

OR the command line prompt
Code:
gimp-2.10.exe -i -b '(script-fu-test "stringy thingy TEST")' -b "(gimp-quit 0)"

then the GIMP output window only reports that the 'batch command executed successfully'; but this is clearly not the case, since if it had executed at all, then it should have written at least "no variable TEST!" to the GIMP output console!

Further experiments with the command line syntax have done no good: using escape characters as in
Code:
gimp-2.10.exe -i -b "(script-fu-test \"stringy thingy\")" -b "(gimp-quit 0)" 

causes GIMP to halt, reporting an 'Error: Error reading string'.

I'm not sure what I'm doing wrong here: I've based my code on the example given on the gimp website's basic batch tutorial (I can't post a link as a new user, but it's the first result on Google when searching for "gimp batch processing"), and tried formatting my command line prompt based on examples shown on forums like this one, but my command line doesn't seem to be willing to execute any code to which I'm passing a string, yet it doesn't give me any error messages either, instead acting as though the script executed despite that clearly not being the case.

Re: Cannot run test script-fu script via console

Sat Jun 05, 2021 3:44 pm

Hello, :)

I don't know Scheme well. I believed that "define" always take only two arguments. Is it the case ? If so, I would think you can fix it by add "begin".

Hope this helps.

Re: Cannot run test script-fu script via console

Sat Jun 05, 2021 4:57 pm

Did you try python instead?

https://stackoverflow.com/questions/444 ... 0#44435560

Re: Cannot run test script-fu script via console

Sat Jun 05, 2021 6:38 pm

ofnuts wrote:Did you try python instead?


I must be honest: I've spent hours on this already to the point where I've realized Python would be more efficient (went ahead and re-installed Python on my machine even before making this thread), but I'm also so frustrated by script-fu/scheme that I really want to "beat" this issue, efficiency be damned. I was hoping there was a simple fix that more experienced folks would be able to help me with, but if this is a really arcane problem I will just give up on the script-fu side of things and jump to Python.

Re: Cannot run test script-fu script via console

Sun Jun 06, 2021 1:46 am

Give this a try:
Code:
(define (script-fu-test strpass)
(begin
  (gimp-message "no variable TEST!")
  (gimp-message (string-append "TEST! with" strpass))
)
)


and use the escaped double-quotes version of the command line.

Re: Cannot run test script-fu script via console

Sun Jun 06, 2021 1:11 pm

paynekj wrote:Give this a try:
Code:
(define (script-fu-test strpass)
(begin
  (gimp-message "no variable TEST!")
  (gimp-message (string-append "TEST! with" strpass))
)
)


and use the escaped double-quotes version of the command line.


I tried this, but it's reproducing the same odd behavior of the initial script, either failing to work due to bad or missing arguments, or else "successfully" running without even executing the unappended gimp-message function.

Re: Cannot run test script-fu script via console

Mon Jun 07, 2021 3:56 am

Works perfectly for me:

Code:
C:\temp>"\Program Files\GIMP 2.10\bin\gimp-console-2.10.exe" -i -b "(script-fu-test \"stringy thingy\")" -b "(gimp-quit 0)"
script-fu.exe-Warning: no variable TEST!

script-fu.exe-Warning: TEST! withstringy thingy

batch command executed successfully


testusername.scm
(149 Bytes) Downloaded 89 times


Be careful that you haven't created two versions of script-fu-test as all scripts share the same name-space and if you've got a second version it will overwrite the first in memory, but how the overwrite happens will depend on which order the files are loaded.

Re: Cannot run test script-fu script via console

Tue Jun 08, 2021 5:40 am

TestUserName wrote:
ofnuts wrote:Did you try python instead?


I must be honest: I've spent hours on this already to the point where I've realized Python would be more efficient (went ahead and re-installed Python on my machine even before making this thread), but I'm also so frustrated by script-fu/scheme that I really want to "beat" this issue, efficiency be damned. I was hoping there was a simple fix that more experienced folks would be able to help me with, but if this is a really arcane problem I will just give up on the script-fu side of things and jump to Python.


If you are on windows you shouldn't install Python (or at least be very careful). AFAIK installing Python after Gimp breaks the Python support in Gimp (which comes with its own Python which conflicts with the one installed separately). Things can possibly work if you install Python first and then Gimp.
Post a reply