Page 1 of 1

Using toolbar custom button to run bash script

Posted: Wed Dec 30, 2020 10:04 pm
by noldo
Hi,
I am looking for a way to run a bash or python script. The easiest way I come across is creating a custom button. But I am not able to get it working attaching .sh file to the command. Is it somehow possible? I believe that exe and bat files won't work for me as I work on unix(Fedora). Thank you.

Re: Using toolbar custom button to run bash script

Posted: Thu Dec 31, 2020 8:31 am
by xnview
are you able to assiociate your button to the script?

Re: Using toolbar custom button to run bash script

Posted: Thu Dec 31, 2020 9:16 am
by noldo
No I am not. After selecting .sh file, marked as executable and working using terminal, it doesn't give me any sort of error message, but it still shows only _cmd_ . This should change when correctly associated with the script, right? Thanks.

Re: Using toolbar custom button to run bash script

Posted: Thu Dec 31, 2020 10:19 am
by xnview
no, you 'll see only __cmd__, you can check in your toolbar.ini

Re: Using toolbar custom button to run bash script

Posted: Thu Dec 31, 2020 10:50 am
by noldo
Okey, I am not able to find toolbar.ini, but I found .bar file and it says:
_cmd_=mylabel;/home/user/somepath/test.sh;
It seems that is is associated with the button.

Edit:
Actually, I am not sure how to find out that the script executed. I used echo(prints to stdout) and touch(creates new file). Is there stdin configured? What should be the pwd(path working directory) of the script? Thanks a lot.

Re: Using toolbar custom button to run bash script

Posted: Fri Jan 08, 2021 7:51 am
by noldo
Any help would be appreciated :), thanks a lot.

Re: Using toolbar custom button to run bash script

Posted: Fri Jan 08, 2021 9:13 am
by xnview
noldo wrote: Fri Jan 08, 2021 7:51 am Any help would be appreciated :), thanks a lot.
it uses the current working folder, so not necessarily the folder of selected file.

Re: Using toolbar custom button to run bash script

Posted: Wed Jan 13, 2021 1:58 pm
by noldo
In my case it uses home folder(Fedora linux). I guess that running python script directly is not possible? I am trying to open a new terminal window to allow me further communication with the python script or seeing the result. I am using bash command:
gnome-terminal -e 'sh -c "python3 /path/python_script.py;read"'
This works for me when I run in from terminal, but doesn't work from clicking the button. Do you have any idea why? Thanks.

Re: Using toolbar custom button to run bash script

Posted: Wed Feb 24, 2021 1:21 pm
by noldo
Hi, I found out that after updating XnView MP to newest version everything started working. Thanks for help.