Ozan Mudul
Ozan Mudul

Reputation: 1010

Linux shell dialog menu having more than 10 items problem

Here I am having an array which are SSID's of nearby wifi

my_array=( $(for i in $(ls /sys/class/net/ | egrep -v ^lo$); do sudo iw dev $i scan | grep SSID | awk '{print substr($0, index($0,$2)) }'; done 2>/dev/null | sort -u) )

dialog --notags --title "Networks" \
         --menu "Choose a network" \
         26 100 100 ${my_array[@]}       

I want to put them into a simple dialog then when selected, join the network. Here I have a problem tho, I indeed searched a lot not only stackoverflow but in search engines too. I couldn't find what to do? If I am not wrong we can create paged menus, I have or will have more than 10 elements in this menu but it only shows 10 elements. I need help at this state, what should I do?

[widmore@widsarch Project2]$ my_array=( $(for i in $(ls /sys/class/net/ | egrep -v ^lo$); do sudo iw dev $i scan | grep SSID | awk '{print substr($0, index($0,$2)) }'; done 2>/dev/null | sort -u) )
[widmore@widsarch Project2]$ declare -p my_array
declare -a my_array=([0]="ardaalara" [1]="Ecem" [2]="Filiz" [3]="GOKHAN" [4]="Kocev" [5]="MSD3" [6]="Mudul" [7]="Murat" [8]="Kaya" [9]="Overlord" [10]="PackPower" [11]="Selin" [12]="SUPERONLINE_WiFi_2558" [13]="SUPERONLINE_WiFi_2979" [14]="SUPERONLINE_WiFi_5887" [15]="SUREL" [16]="TANOOO" [17]="TTNET_ZyXEL_9JWH" [18]="TurkTelekom_T4F9D" [19]="TurkTelekom_T5DB8" [20]="TurkTelekom_TCFB7" [21]="Zyxel_8499")

Upvotes: 0

Views: 339

Answers (2)

Ivan
Ivan

Reputation: 7257

you'r going to the rigth direction but chose wrong option. Use --noitem instead of --notags.

Upvotes: 0

KamilCuk
KamilCuk

Reputation: 140960

Dialog --menu works like

dialog --menu text height width menu-height tag1 item1 tag2 item2 tag3 item3 etc...

Each item has a tag, see man dialog. You need for example insert numbers in front of each array element.

my_array2=($(
   i=1
   for j in "${my_array[@]}"; do
      echo "$i"
      echo "$j"
      i=$((i+1))
   done
))
dialog ... --menu ... "${my_array2[@]}"

Upvotes: 1

Related Questions