1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Zenity and bash script, help please!

Discussion in 'Linux & Open Source' started by Malt_Vinegar, Jan 9, 2020.

  1. Malt_Vinegar

    Underboss

    Joined: Oct 20, 2002

    Posts: 15,042

    Location: In a house

    Hi Guys,

    Trying to knock up a script to change a variable, depending on answers:

    #! /bin/bash
    ans=$(zenity --list --text "Select your Domain" --radiolist --column "Pick" --column "Domain" TRUE UK FALSE US FALSE EUR);
    if (( $ans == US ));
    then
    setparam ica.pnlogin.browseraddress_store1.server US.cloud.com:443
    .
    elif (( $ans == UK ));
    then
    setparam ica.pnlogin.browseraddress_store1.server UK.cloud.com:443
    .
    elif (( $ans == EUR ));
    then
    setparam ica.pnlogin.browseraddress_store1.server EUR.cloud.com:443
    .
    fi

    This is where I have got to, but its not working correctly! The "setparam" command does work, and if i just have an Else/IF with two options, it seems to work fine. However, I will have 3+ options to use in this scenario, and I am tweaking away like mad and failing.

    I am new to bash scripting, so be gentle please :D
     
  2. AmateurExpert

    Gangster

    Joined: Aug 7, 2017

    Posts: 410

    Location: location location

    Firstly - use single or double square brackets [] [[]] for your test expressions not double round brackets - the latter only applies for numeric expressions. I think this Linux Academy article is quite helpful.

    Secondly - bash has the case keyword for multiple options - look it up, as it should result in easier to read code.