Powershell hook-script for gPhoto2 running on Windows10


I try to use a hook-script on gPhoto2 running on Windows10 installed via MSYS2 MinGW. gPhoto2 is working quite well. My problem is now that I like to run a hook-script reacting on the events from the camera. I start the gPhoto tethered capture with this code:

    gphoto2 --auto-detect
    gphoto2 --capture-tethered --filename "%Y-%m-%d_%H%M%S.%C" --hook-script "D:\gphoto2Testing\Test.ps1"

For testing purposes the code of 'Test.ps1' is just

exit 0

because as far as I understood the gPhoto2 documentation one need a zero exit code for the init action. Nevertheless I get the following error:

    gphoto2 : Hook script returned error code -1 (0xffffffff)
    In D:\gphoto2Testing\gPhoto2.ps1:6 Zeichen:1
    + gphoto2 --capture-tethered --filename "%Y-%m-%d_%H%M%S.%C" --hook-scr ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (Hook script ret...-1 (0xffffffff):String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError
    Hook script "D:\gphoto2Testing\Test.ps1" init failed. Aborting.

In general the hook-script should be script-type agnostic (see https://github.com/gphoto/gphoto2/issues/217). The demo hook-script which ships with gPhoto2 reads:

    self=`basename $0`
    case "$ACTION" in
        echo "$self: INIT"
        # exit 1 # non-null exit to make gphoto2 call fail
        echo "$self: START"
        echo "$self: DOWNLOAD to $ARGUMENT"
        echo "$self: STOP"
        echo "$self: Unknown action: $ACTION"
    exit 0

The docs of gPhoto2 reads:

Execute the hook script FILENAME every time a certain event happens within gphoto2. The hook script reads the environment variable ACTION. It must ignore ACTION values unknown to it.

Maybe my problem is somehow related to the environment variable ACTION or the above mentioned exit code. I searched on google but without any sucess. Any help to solve this problem is much appreciated.

asked on Stack Overflow Aug 28, 2020 by joking

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0