Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

2 votes
2 answers
2074 views
Displaying messages to tty using whiptail through monit
I would like to display a [`whiptail`](http://manpages.ubuntu.com/manpages/intrepid/man1/whiptail.1.html) message on the login screen that is triggered by `monit`, but I am without luck. I understand it might be something to do with interactive/non-interactive shell. Here is the script that gets tri...
I would like to display a [whiptail](http://manpages.ubuntu.com/manpages/intrepid/man1/whiptail.1.html) message on the login screen that is triggered by monit, but I am without luck. I understand it might be something to do with interactive/non-interactive shell. Here is the script that gets triggered by monit. #!/bin/bash /usr/bin/whiptail --infobox 'Hello World.' 7 25 >/dev/tty1 Is there a trick, or should I avoid using whiptail?
Yuri (121 rep)
Jul 24, 2013, 11:59 PM • Last activity: Apr 18, 2025, 05:04 AM
0 votes
1 answers
145 views
Setting Whiptail yesno default to no
Is there a way to have the whiptail yesno choice box set to default no ? if (whiptail --title "STEAM GAME SERVER 1" --yesno "ARE YOU SURE TO REBOOT LINUX OS?" 10 60) then "Yes" is the default highlighted choice, I would like to have "no" set as deafult in case when someone it to quickly in hitting t...
Is there a way to have the whiptail yesno choice box set to default no ? if (whiptail --title "STEAM GAME SERVER 1" --yesno "ARE YOU SURE TO REBOOT LINUX OS?" 10 60) then "Yes" is the default highlighted choice, I would like to have "no" set as deafult in case when someone it to quickly in hitting the keyboard button
Sunyata Nothing (1 rep)
Aug 2, 2024, 09:43 AM • Last activity: Aug 2, 2024, 11:28 AM
1 votes
1 answers
140 views
Is it possible to periodially refresh a whiptail dialog?
I have a whipail dialog where I display a dashboard: ```bash source ../script/includes/tasks pick_task () { local options=( "$LOGS_TASK" "Check the logs of a service" "$KILL_TASK" "Kills a service" "$KILL_ALL_TASK" "Kills all services" "$SELECT_TASK" "Allows you to select the services you want to ru...
I have a whipail dialog where I display a dashboard:
source ../script/includes/tasks

pick_task () {
    local options=(
        "$LOGS_TASK" "Check the logs of a service"
        "$KILL_TASK" "Kills a service"
        "$KILL_ALL_TASK" "Kills all services"
        "$SELECT_TASK" "Allows you to select the services you want to run" 
    )

    local menu_height="${#options[@]}"
    local dialog_height=$((menu_height + 9))
    local dialog_width=80

    result=$(whiptail --title "Dashboard" --menu "What do you want to do?" "$dialog_height" "$dialog_width" "$menu_height" "${options[@]}" 3>&1 1>&2 2>&3)
    echo $result
}
This works fine but I'd like to also display some additional information in this window that dynamically refreshes. Is it possible to refresh this dialog while it is open?
Adam Arold (133 rep)
Mar 23, 2024, 05:59 PM • Last activity: Mar 24, 2024, 07:29 PM
2 votes
1 answers
1792 views
Make whiptail work in a for loop
I have a bash script that checks ping for 163 sites(stores around the country), which is this: #!/bin/bash #storestest.sh #version 0.9.2 clear; printf "Check stores procedure started; `date +"%d/%m/%Y %H:%M:%S"`\n"; declare -a STORESITE=($(cat 'stores.txt' | awk -F, '{print $1}')); # Declaring an ar...
I have a bash script that checks ping for 163 sites(stores around the country), which is this: #!/bin/bash #storestest.sh #version 0.9.2 clear; printf "Check stores procedure started; date +"%d/%m/%Y %H:%M:%S"\n"; declare -a STORESITE=($(cat 'stores.txt' | awk -F, '{print $1}')); # Declaring an array and populated by the file stores.txt declare -i UP=0; # Create a variable to serve as a counter for stores that are up declare -i DOWN=0; # Create a variable to serve as a counter for stores that are down touch storesdown.txt; # Create a file if does not exist to store the list of the store the stores that are down printf "" > storesdown.txt; # Clear the contents of the file touch storesup.txt; # Create a file if does not exist to store the list of the store the stores that are up printf "" > storesup.txt; # Clear the contents of the file whiptail --title "Testing stores connectivity" --backtitle "Store Test" --yes-button "OK" --no-button "Cancel" --yesno "Check stores procidure has started" 10 50 if [ $? -ne 0 ]; then exit; fi for i in "${STORESITE[@]}" ; do ping -c 3 $i > /dev/null 2> /dev/null; if [ $? -eq 0 ]; then echo "$i is up" >> storesup.txt; let UP++ sleep 1 else echo "$i is down" >> storesdown.txt; let DOWN++ sleep 1 fi printf "Total: $UP are online and $DOWN are off line.\r"; done echo "Total: $UP are online and $DOWN are off line."; exit; The above script is working fine but I decided to make it a bit fancier by adding a gauge to show the total progress of it. So here is what I did next: #!/bin/bash #storestest.sh #version 0.9.3 clear; printf "Check stores procedure started; date +"%d/%m/%Y %H:%M:%S"\n"; declare -a STORESITE=($(cat 'stores.txt' | awk -F, '{print $1}')); # Declaring an array and populated by the file stores.txt declare -i UP=0; # Create a variable to serve as a counter for stores that are up declare -i DOWN=0; # Create a variable to serve as a counter for stores that are down touch storesdown.txt; # Create a file if does not exist to store the list of the store the stores that are down printf "" > storesdown.txt; # Clear the contents of the file touch storesup.txt; # Create a file if does not exist to store the list of the store the stores that are up printf "" > storesup.txt; # Clear the contents of the file whiptail --title "Testing stores connectivity" --backtitle "Store Test" --yes-button "OK" --no-button "Cancel" --yesno "Check stores procidure has started" 10 50 if [ $? -ne 0 ]; then exit; fi total="${#STORESITE[*]}"; { for ((g = 0; g /dev/null 2> /dev/null; if [ $? -eq 0 ]; then echo "$i is up" >> storesup.txt; let UP++ sleep 2 else echo "$i is down" >> storesdown.txt; let DOWN++ sleep 2 fi printf "Total: $UP are online and $DOWN are off line.\r"; done sleep 1 echo $g done } | whiptail --gauge "Please wait" 6 60 0 echo "Total: $UP are online and $DOWN are off line."; exit; Which does not work as I thought it should be.... That was the best way I could think and write to make at least the whiptail work, but apparently what it happens is to skip the nested loop. P.S I know some of my coding is obsolete and old fashion way of bash scripting.
ChrisH (21 rep)
Nov 25, 2015, 01:32 AM • Last activity: Oct 26, 2023, 05:08 PM
1 votes
1 answers
1180 views
Create an array from the output of whiptail command
So, I am trying to use `whiptail` command to give users option to choose different things they want to install in their system. I use the `whiptail --checklist` command as below: name =$(whiptail --title "Tools to install" --checklist 20 78 4 \ "NTP" "NTP setup" OFF\ "Perl" "Perl install" OFF\ "Ruby...
So, I am trying to use whiptail command to give users option to choose different things they want to install in their system. I use the whiptail --checklist command as below: name =$(whiptail --title "Tools to install" --checklist 20 78 4 \ "NTP" "NTP setup" OFF\ "Perl" "Perl install" OFF\ "Ruby" "Ruby install" OFF \ "Python" "Python install" OFF 3>&1 1>&2 2>&3) Now, if my users choose Perl and python, this will output "Perl" and "Python". What I am looking for is to be able to convert these outputs into an array because ultimately I need to loop through this array. I need to feed these outputs as inputs to next command I am using. Any help or lead will be highly appreciated!
BishwashK (23 rep)
Jul 12, 2022, 04:36 PM • Last activity: Jul 12, 2022, 04:56 PM
4 votes
2 answers
10063 views
Array into whiptail menu - BASH
I would like to show user friendly `whiptail` menu. My goal in `whiptail` is this: Choice1 Choice2 Choice3 Choice4 I have array consist of: Choice1 Choice2 Choice3 Choice4 I run array through loop for like this: for value in ${value[@]} do echo "$value" done I could not add `whiptail` inside echo be...
I would like to show user friendly whiptail menu. My goal in whiptail is this: Choice1 Choice2 Choice3 Choice4 I have array consist of: Choice1 Choice2 Choice3 Choice4 I run array through loop for like this: for value in ${value[@]} do echo "$value" done I could not add whiptail inside echo because I get 4 another menus. I tried script like this: $val=$(whiptail --title "xx" --menu "choose" 16 78 10 for value in ${value[@]} do echo "$value" done 3>&1 1>&2 2>&3) After run above mentioned script my shell looks horrible. shell after script: enter image description here Is there anybody who solve my problem?
Michal N. (141 rep)
Jan 1, 2016, 07:43 PM • Last activity: Nov 22, 2021, 07:46 AM
1 votes
2 answers
1158 views
No keyboard output on terminal after running a script using read and whiptail
I've written a bash function that accepts a command as an argument, runs it in the background, and allows the user to kill the command by pressing any key. This part works fine. However, when I pipe it to a `whiptail` dialog gauge, the whiptail runs as expected, but after it returns, the terminal wi...
I've written a bash function that accepts a command as an argument, runs it in the background, and allows the user to kill the command by pressing any key. This part works fine. However, when I pipe it to a whiptail dialog gauge, the whiptail runs as expected, but after it returns, the terminal will no longer display keypresses. I can still run commands, I just don't see what I'm typing printed to the screen. The output is also formatted weirdly, where stdout appears after $. I'm pretty sure the read command is responsible for this behavior, but I don't understand why. Can anyone offer any insight?
#!/bin/bash
function killOnKeypress() {
	local runcommand="${1}"
	local args=(${@:2})

	# Run the command in the background
	"${runcommand}" ${args[@]} &

	# Get the process id of $runcommand
	local pid=$!

	# Monitor $runcommand and listen for keypress in foreground
	while kill -0 "${pid}" >/dev/null 2>&1; do
		# If key pressed, kill $runcommand and return with code 1
		read -sr -n 1 -t 1 && kill "${pid}" && return 1
	done

	# Set $? to return code of $runcommand
	wait $pid

	# Return $runcommand's exit code
	return $?
}

function count100() {
	for ((i = 0; i < 100; i++)); do
		echo $i
		sleep .02
	done
}

killOnKeypress "count100" | whiptail \
	--gauge "Counting to 100" \
	16 56 \
	0
enter image description here
ridgek (25 rep)
Oct 17, 2021, 10:03 PM • Last activity: Oct 18, 2021, 03:03 PM
0 votes
1 answers
1225 views
Issue with bash Dialog (Whiptail) progress bar
I am trying to create a bash Dialog (whiptail) progress bar for a list of commands. So, that progress bar shows along with messages when the commands get executed one by one in the background. I am using whiptail, this is a Ubuntu server, so, I am not looking at GTK based utilities that require an X...
I am trying to create a bash Dialog (whiptail) progress bar for a list of commands. So, that progress bar shows along with messages when the commands get executed one by one in the background. I am using whiptail, this is a Ubuntu server, so, I am not looking at GTK based utilities that require an Xserver e.g. Zenity, Yad etc. I am very new to bash scripting and I don't know where I am getting wrong any help is appreciated. **System OS: Ubuntu 20.04** **The Issue:** > The messages are getting displayed all at once instead of stages/per > command and all the commands start executing parallelly (all at once) > instead of one by one. Is the code wrong? should I have used for loop > instead of while loop, if then how? **my list of commands:** { sudo apt-get update -y sudo apt-get install nginx -y sudo systemctl reload nginx sudo add-apt-repository ppa:ondrej/php -y sudo apt-get -y install php-fpm sudo apt-get install mariadb-server -y } **This is the code for the progress bar:** #!/usr/bin/env bash ( msgs=( "Preparing install..." "Starting Nginx installation..." "Nginx installation completed successfully" "Starting Mariadb installation..." "Starting PHP installation..." "PHP installation completed successfully" ) items=$( { #echo "Preparing install..." sudo apt-get update -y #echo "Starting Nginx installation..." sudo apt-get install nginx -y #echo "Nginx installation completed successfully" sudo systemctl reload nginx #echo "Starting Mariadb installation..." sudo apt-get install mariadb-server -y #echo "Starting PHP installation..." sudo add-apt-repository ppa:ondrej/php -y sudo apt-get -y install php-fpm #echo "PHP installation completed successfully" sudo systemctl reload nginx } | wc -l) processed=0 while [ $processed -le $items ]; do pct=$(( $processed * 100 / $items )) echo "XXX" echo $processed echo ${msgs["$processed"]} echo XXX echo "$pct" processed=$((processed+1)) sleep 1 done ) | whiptail --title "Gauge" --gauge "Please wait..." 10 60 0 **These are the messages:** msgs=( "Preparing install..." "Starting Nginx installation..." "Nginx installation completed successfully" "Starting Mariadb installation..." "Starting PHP installation..." "PHP installation completed successfully" )
depar (89 rep)
Sep 16, 2021, 08:36 PM • Last activity: Sep 17, 2021, 11:33 AM
25 votes
4 answers
35713 views
whiptail or dialog
I am going to create a script which will use user input, so I decided to use `whiptail`. But now I'm a little bit confused about which one is portable and will work on Ubuntu 10.x and higher and CentOS 5.x and higher. I know `read`, but I want a tool like `dialog`. If anybody knows any alternative j...
I am going to create a script which will use user input, so I decided to use whiptail. But now I'm a little bit confused about which one is portable and will work on Ubuntu 10.x and higher and CentOS 5.x and higher. I know read, but I want a tool like dialog. If anybody knows any alternative just let me know.
Rahul Patil (25515 rep)
Feb 13, 2013, 09:25 AM • Last activity: Mar 9, 2021, 06:27 PM
1 votes
1 answers
489 views
Is it possible to edit a file in whiptail?
For a new TUI, I want to employ whiptail or dialog to make it a bit more visually appealing. Afaik, whiptail is more widely available and even preinstalled on many systems, which is a good reason to use it. (Is that still true?) But a nice-to-have feature would be to be able to seamlessly edit files...
For a new TUI, I want to employ whiptail or dialog to make it a bit more visually appealing. Afaik, whiptail is more widely available and even preinstalled on many systems, which is a good reason to use it. (Is that still true?) But a nice-to-have feature would be to be able to seamlessly edit files in the TUI. In dialog, there is the option --editbox. **Is there something similar for whiptail?** I couldn't find it in the man pages, but it would not be the first time, that I am just not seeing something O_o .
steffen (135 rep)
Feb 23, 2021, 08:37 PM • Last activity: Feb 23, 2021, 09:19 PM
1 votes
2 answers
2782 views
lftp whiptail progress bar
I am using the following command in a bash script to download files from an ftp server. This command uses the -v option which shows the name of each file being downloaded. /usr/bin/lftp ftp://$ftpuser:$ftppass@$ftphost -e "$ftpsettings ; mirror -v -e $remotemedia $localmedia ; quit" I need to modify...
I am using the following command in a bash script to download files from an ftp server. This command uses the -v option which shows the name of each file being downloaded. /usr/bin/lftp ftp://$ftpuser:$ftppass@$ftphost -e "$ftpsettings ; mirror -v -e $remotemedia $localmedia ; quit" I need to modify the script, to display a progress bar using whiptail, to show the download progress. This is the progress bar, but I don't know how to make it read the lftp download progress. { for ((i = 0 ; i <= 100 ; i+=5)); do sleep 0.1 echo $i done } | whiptail --gauge "Downloading file $name..." 6 50 0 How can I do this?
aristosv (93 rep)
Jun 2, 2016, 12:07 PM • Last activity: Jan 17, 2021, 06:53 AM
0 votes
0 answers
2998 views
How to show a progress bar for lftp script for newer version of lftp in 2020?
I have read [this](https://unix.stackexchange.com/q/287186/29193) question and its answer, but they do not answer my question. The shell script is this: ```bash let total=$(lftp -f lftp-script-count.txt | wc -l)-2 lftp -f lftp-script.txt | while read word word2 filename do if [ "$word" = Transferrin...
I have read [this](https://unix.stackexchange.com/q/287186/29193) question and its answer, but they do not answer my question. The shell script is this:
let total=$(lftp -f lftp-script-count.txt | wc -l)-2

lftp -f lftp-script.txt |

while read word word2 filename
do
    if [ "$word" = Transferring ]
    then let count=count+1
         let percent=count*100/total
         echo -e "XXX\n$percent\nDownloading $filename\nXXX"
    fi
done |

whiptail --title lftp --gauge progress 10 60 0
The **lftp-scrip-count.txt** lftp script works well:
debug 10
set ssl:verify-certificate no
open ...
user ... ...
cd ...
ls -R .
The **lftp-scrip-count.txt** lftp script works slow (but works for sure although I would love it to work faster) and the progress does not get to whiptail:
set ssl:verify-certificate no
open ...
user ...
cd ...
mirror -P=10 . lftp-works --exclude-glob=node_modules
quit
The result is that the progress bar is shown but remains at 0% till the end although it got to download the entire 251MB. If I resize the terminal window the whiptail screen does not get repainted. When it reaches the end of the download, the progress bar window disappears well. It seems to me that the procent shown by the simple lftp -f lftp-script.txt is not global. The output of this command contains, besides the percent, things like this: * Waiting for response... * Receiving data/TLS * Making data connection... * Receiving data... Example: screenshot **My question is:** How can I get the progress bar to show the progress well? Is there another CLI FTP client that shows the progress and is good for my requirements as seen in the lftp scripts shown above? Thank you. # Update 1 There are 2 remaining issues: 1. It would be great if I could show the progress of the operation relative to the total number of files that will be copied, not all the files available to be copied, because I use --only-newer. 2. Keeping (1) in mind, it would be interesting to find out why with --only-newer it has the same speed like without it, when the directory is already completely downloaded. If I could make the process faster it would be great.
silviubogan (149 rep)
Mar 23, 2020, 06:28 AM • Last activity: Mar 23, 2020, 02:00 PM
1 votes
1 answers
428 views
how to change the input box color while using form property in shell script using dialog
[![enter image description here][1]][1] how to change the input box color while using form property in shell script using dialog [1]: https://i.sstatic.net/SFScz.png
enter image description here how to change the input box color while using form property in shell script using dialog
Manikandan (11 rep)
May 28, 2019, 06:49 AM • Last activity: May 28, 2019, 09:48 AM
0 votes
0 answers
40 views
Monitor Apache Selectively
I am working to parse apache logs in Common Format in realtime so that I monitor them while I work. "tail -F /var/log/apache2/access.log" works but provides more than I need. "awk '{print $1 " " $2 " " $3 " " $4 " "}'access.log " gives the parts I need but of course runs x1 and I do not know the bas...
I am working to parse apache logs in Common Format in realtime so that I monitor them while I work. "tail -F /var/log/apache2/access.log" works but provides more than I need. "awk '{print $1 " " $2 " " $3 " " $4 " "}'access.log " gives the parts I need but of course runs x1 and I do not know the bash well enough (yet!) to loop on something like file change etc. So I would like to pipe "|" the output of the tail expression above to the awk expression above. Also, I would like for this output to print last line of the access.log at the top of the screen, not the bottom.
Dahere (11 rep)
Apr 10, 2019, 06:13 PM • Last activity: Apr 10, 2019, 10:40 PM
0 votes
1 answers
1070 views
Total Progress over entire bash shell script
EDIT FOR CLARITY : say I have the following script (let's posit pv and curl are already installed) : (that currently runs under ubuntu but that I plan to make POSIX-compliant so that it may run on more linux ditributions) #!/bin/bash sudo apt install vlc mkdir -p ~/.steam/compatibilitytools.d PROTON...
EDIT FOR CLARITY : say I have the following script (let's posit pv and curl are already installed) : (that currently runs under ubuntu but that I plan to make POSIX-compliant so that it may run on more linux ditributions) #!/bin/bash sudo apt install vlc mkdir -p ~/.steam/compatibilitytools.d PROTONVERSIONNUMBER=$(curl -v --silent https://api.github.com/repos/popsUlfr/Proton/releases 2>&1 | grep "tag_name" | head -n 1 | cut -f4,4 -d"\"") REPLACING=$(curl -v --silent https://api.github.com/repos/popsUlfr/Proton/releases 2>&1 | grep "target_commitish" | head -n 1 | cut -f4,4 -d"\"" | sed "s/[^_]\+/\L\u&/g") PROTONVERSION=${REPLACING/_G/-6_G} PROTONNAME=$PROTONVERSION"_"${PROTONVERSIONNUMBER##*-} wget https://github.com/popsUlfr/Proton/releases/download/$PROTONVERSIONNUMBER/$PROTONNAME.tar.xz pv $PROTONNAME.tar.xz | tar xp -J -C ~/.steam/compatibilitytools.d rm $PROTONNAME.tar.xz I get three progress bars, these progress bars seem very beautiful to me : the way they're accurate and stuff, I dunno call me a weirdo QUESTION ------ How do I utilize the power of these three seperate progress bars to form one continuous progress bar that respects currents progress bar "speeds" of the underlying "true" progress bars?
tatsu (306 rep)
Mar 8, 2019, 10:33 AM • Last activity: Mar 8, 2019, 02:14 PM
1 votes
2 answers
1755 views
Whiptail/dialog input bug when executed from rc.local
I need to start a Bash script containing calls to dialog at Debian boot time. This is how I've been able to do it: * Unset default root password * Set *--autologin* option to tty1 in *initrd* (*1:2345:respawn:/sbin/getty --autologin root tty1*) * Write the full path of my script in */etc/rc.local* H...
I need to start a Bash script containing calls to dialog at Debian boot time. This is how I've been able to do it: * Unset default root password * Set *--autologin* option to tty1 in *initrd* (*1:2345:respawn:/sbin/getty --autologin root tty1*) * Write the full path of my script in */etc/rc.local* However, dialog has an unusual behaviour: the box appears, but then stdin seems to be overflowing stdout. When I press the arrow keys, no button is selected, but instead, corresponding ASCII chars are displayed on top of the dialog box, starting from the default choice position: ![display bug in dialog](https://i.sstatic.net/CFSyw.png) Note that if I then press enter, the keys are sent to dialog and corresponding option is selected as intended. The script has been testing working when executed normally. I suppose something is missing in the shell initialization: if I put /bin/bash in rc.local, I get no job control in this shell message, and can't send signal to processes nor get pids (I get question marks instead of pids in top). Why is this behaviour and how can I overcome it?
pedroapero (634 rep)
Apr 30, 2015, 09:12 AM • Last activity: Feb 10, 2019, 11:43 PM
-2 votes
1 answers
971 views
Changing font size in whiptail dialog boxes
I've made script using a few different whiptail boxes, which all work fine, but I'd like the font size to be larger. All my google searches on _whiptail font size_ tell me either about whiptail box sizes, or about font sizes not related to whiptail. And nothing on the man page. Is there a way to cha...
I've made script using a few different whiptail boxes, which all work fine, but I'd like the font size to be larger. All my google searches on _whiptail font size_ tell me either about whiptail box sizes, or about font sizes not related to whiptail. And nothing on the man page. Is there a way to change the whiptail font size?
user3075315 (1 rep)
Dec 10, 2018, 09:04 PM • Last activity: Dec 10, 2018, 09:12 PM
0 votes
1 answers
865 views
Dynamic options on whiptail got not printed
I have a json file which provides options for a 'whiptail' checkbox or radiolist. I grab them, make some redactions and wanna use them to show as options: `defaults.json` file: {"displays": [ {"id": "320x240", "default":"on", "description":"320x240 (native resolution of 3.2 TFT-Display)", "hdmi_grou...
I have a json file which provides options for a 'whiptail' checkbox or radiolist. I grab them, make some redactions and wanna use them to show as options: defaults.json file: {"displays": [ {"id": "320x240", "default":"on", "description":"320x240 (native resolution of 3.2 TFT-Display)", "hdmi_group":"2", "hdmi_mode":"87","hdmi_cvt":"320 240 60 1 0 0 0"}, {"id": "640x480", "default":"off", "description":"640x480", "hdmi_group":"2","hdmi_mode":"87", "hdmi_cvt":"3240 240 60 1 0 0 0"}, {"id": "720x540", "default":"off", "description":"720x540", "hdmi_group":"2","hdmi_mode":"87", "hdmi_cvt":"3240 240 60 1 0 0 0"}, {"id": "800x600", "default":"off", "description":"800x600", "hdmi_group":"2","hdmi_mode":"87", "hdmi_cvt":"3240 240 60 1 0 0 0"}, {"id": "1024x768", "default":"off", "description":"1024x768", "hdmi_group":"2","hdmi_mode":"87", "hdmi_cvt":"3240 240 60 1 0 0 0"}, {"id": "1280x720", "default":"off", "description":"1280x720 (16:9)", "hdmi_group":"2","hdmi_mode":"87", "hdmi_cvt":"3240 240 60 1 0 0 0"}, {"id": "1600x900", "default":"off", "description":"1600x900 (16:9)", "hdmi_group":"2","hdmi_mode":"87", "hdmi_cvt":"3240 240 60 1 0 0 0"}, {"id": "1920x1080", "default":"off", "description":"1920x1080 (16:9)", "hdmi_group":"2","hdmi_mode":"87", "hdmi_cvt":"3240 240 60 1 0 0 0"} ] } The jq script displays=$(cat defaults.json | jq -r -j '.displays[] | "\(.id) \"\(.description)\" \(.default) "') which gives me the following output (which works when I paste it directly into the [tag item status] position: 320x240 "320x240 (native resolution of 3.2 TFT-Display)" on 640x480 "640x480" off 720x540 "720x540" off 800x600 "800x600" off 1024x768 "1024x768" off 1280x720 "1280x720 (16:9)" off 1600x900 "1600x900 (16:9)" off 1920x1080 "1920x1080 (16:9)" off This one works perfectly: whiptail --title "Display setup" --radiolist "Choose your display" 20 78 8 320x240 "320x240 (native resolution of 3.2 TFT-Display)" on 640x480 "640x480" off 720x540 "720x540" off 800x600 "800x600" off 1024x768 "1024x768" off 1280x720 "1280x720 (16:9)" off 1600x900 "1600x900 (16:9)" off 1920x1080 "1920x1080 (16:9)" off 3>&1 1>&2 2>&3 **BUT** when I try to add them through the variable $displays, whiptail only spits out the "help" file. **This is not working** whiptail --title "Display setup" --radiolist "Choose your display" 20 78 8 $displays 3>&1 1>&2 2>&3 **What I am doing wrong, why is this not working?**
Jan (175 rep)
Nov 3, 2018, 10:20 AM • Last activity: Nov 3, 2018, 11:27 PM
2 votes
1 answers
1438 views
Questions about whiptail and bash functions
- Say I have this script: #!/bin/bash function cpp-lang { yum install "Development Tools" } function updatesys { yum -y update yum -y upgrade } whiptail --checklist "test" 5 40 5\ Update "Update the system" on \ C++ "Install C++" off 2>results while read choice do case $choice in Update )updatesys ;...
- Say I have this script: #!/bin/bash function cpp-lang { yum install "Development Tools" } function updatesys { yum -y update yum -y upgrade } whiptail --checklist "test" 5 40 5\ Update "Update the system" on \ C++ "Install C++" off 2>results while read choice do case $choice in Update )updatesys ;; C++)cpp-lang ;; *) ;; esac done < results When I run it, it exits, should I return something from the function? - Considering the script above as an example, should I run sudo every time I call yum install or is doing sudo ./script.shenough?
Lynob (4434 rep)
Jan 30, 2015, 02:22 PM • Last activity: Aug 21, 2018, 12:37 AM
-1 votes
1 answers
2898 views
Array into whiptail checkbox - BASH
How do I show a `whiptail` checklist from `Array`?
How do I show a whiptail checklist from Array?
Roger Ramos (109 rep)
Dec 20, 2017, 09:26 PM
Showing page 1 of 20 total questions