My code:

read -ra var <<<$(sed -ne's/^ *:\([[:upper:]]*\).*/\1/p' /etc/sysconfig/iptables)
chains=$(whiptail --title "Add rule" --menu "chains" 16 78 5 "${var[@]}" 3>&1 1>&2 2>&3)

I would like to have all avaliable iptables chains in whiptail menu but when I run my script I got this:

screenshot with empty Add rule window

But when I add to whiptail syntax --ok-button I got this:

chains=$(whiptail --title "Add rule" --menu "chains" 16 78 5 --ok-button "${var[@]}" 3>&1 1>&2 2>&3)

screenshot with output forward selection

I know I should write some choice after --ok-button (e.g. Ok) but when I run this script I got what is shown in the first image.

I added beyond --menu tag --notags and I still got what is shown in the first image.

If I delete space:

chains=$(whiptail --title "Add rule" --menu "chains" 16 78 5 --ok-button Ok"${var[@]}" 3>&1 1>&2 2>&3)

I got this:

screenshot with output selection

Well I want to add a tag --notags to show just items in array var

What can I do to fix this problem?

  • It would be easier to follow if you showed the complete script at each point. The pictures are large and a distraction. – Thomas Dickey Dec 29 '15 at 19:57
  • @thomasdickey done – Michal N. Dec 29 '15 at 20:08

The --notags and --ok-button options should go before the --menu option. Those modify the behavior of the menu widget.

The documentation for whiptail needs some work. You might find the manual page for dialog helpful: I see from strings /usr/bin/whiptail that whiptail has a --notags option, but it is not described in whiptail's manual page. In dialog:

          Some  widgets  (checklist, inputmenu, radiolist, menu) display a
          list with two columns (a "tag" and "description").  The  tag  is
          useful  for scripting, but may not help the user.  The --no-tags
          option (from Xdialog) may be used to suppress the column of tags
          from  the  display.  Unlike the --no-items option, this does not
          affect the data which is read from the script

dialog maps --notags to -no-tags (Xdialog implemented the feature first, using the latter name).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.