Paul
Paul

Reputation: 321

Run Shell Script after click on button - YAD

I have three shell scripts and I would like to run each script after click on button in yad - lets say - I have one yad session with three buttons - if I click on one button I will open 1. script - second button open 2. script and so on.. See my example bellow -

#!/bin/bash
files=$(yad --width 100 --height 100 --title "Choose the Shell Script" \
    --text="  Please enter analysis details:" \
    --button="ShellScript1:2" \
    --button="ShellScript2:3" \
    --button="ShellScript3:3" \
    --button="Cancel:1" \
    --on-top \
    --center \
)

ret=$?
[[ $ret -eq 1 ]] && exit 0

Thank you for any idea or help.

Upvotes: 0

Views: 3048

Answers (2)

ludvick
ludvick

Reputation: 11

Optionally, you can use:

--button='ShellScript1:bash -c "script or command"'

Plaeae, have a look here:

How to run other bash scripts on YAD button click?

Upvotes: 1

Paul
Paul

Reputation: 321

I just add condition:

ret=$?

[[ $ret -eq 1 ]] && exit 0

if [[ $ret -eq 2 ]]; then

      /path/to/shell/1.sh
fi

if [[ $ret -eq 3 ]]; then

    /path/to/shell/2.sh

fi

Upvotes: 0

Related Questions