Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
3
votes
1
answers
2158
views
dialog menu to display files, select one of them and then able to delete it
I want to be able to display files under a given directory, then select one of the files and be able to delete it. Here's what I've found so far. Can anybody help? let i=0 # define counting variable W=() # define working array while read -r line; do # process file by file let i=$i+1 W+=($i "$line")...
I want to be able to display files under a given directory, then select one of the files and be able to delete it.
Here's what I've found so far. Can anybody help?
let i=0 # define counting variable
W=() # define working array
while read -r line; do # process file by file
let i=$i+1
W+=($i "$line")
done &2 2>&1 1>&3) # show dialog and store output
clear
if [ $? -eq 0 ]; then # Exit with OK
readlink -f $(ls -1 /home | sed -n "
echo "$FILE p" | sed 's/ //'
")
fi
NickG95
(31 rep)
Mar 14, 2016, 09:50 AM
• Last activity: Jun 27, 2025, 06:04 AM
3
votes
3
answers
2132
views
curl progress in dialog
how can i properly display the curl progress in the dialog window? curl http://mysite.corp/image/root_21.tar.bz2 | tar -C /mnt/dest/ -jxf - [![enter image description here][1]][1] i tried this command but as you can see it does not display it correctly. curl -f -x '' -L http://mysite.corp/image/root...
how can i properly display the curl progress in the dialog window?
curl http://mysite.corp/image/root_21.tar.bz2 | tar -C /mnt/dest/ -jxf -
i tried this command but as you can see it does not display it correctly.
curl -f -x '' -L http://mysite.corp/image/root_21.tar.bz2 | tar -C /mnt/dest -xjpf - --exclude='dev/*' | dialog --backtitle "dialog" --stderr --title 'Linux Image' --textbox /tmp/log 30 80
this command almost helps me but i want it to overwrite itself and not show me new line progress in each line. basically i want it to be the same as the original command shows it but in the dialog.
(curl -f -x '' -L http://mysite.corp/image/root_21.tar.bz2 | tar -C /mnt/dest -xjpf - --exclude='dev/*' ) 2>&1 | dialog --progressbox 20 120



Asaf Magen
(547 rep)
Sep 7, 2015, 09:12 AM
• Last activity: Jun 8, 2025, 02:01 PM
0
votes
1
answers
2068
views
PV command to show progress in Dialog with transfer rate in Mbits
I am using PV -n command to read partitions and using gzip with pipe to compress the read data and storing the file. While data is read and written I am using a while loop to show progress using linux dialog utility. This works great, progress is updated. I want to also display the transfer speed /...
I am using PV -n command to read partitions and using gzip with pipe to compress the read data and storing the file. While data is read and written I am using a while loop to show progress using linux dialog utility.
This works great, progress is updated. I want to also display the transfer speed / read speed in Mbits. Also I want to update the DB table with progress as well as transfer speed in Mbits.
Since I am using a while loop to read each line, progress should be displayed on a new line for every update. See below my code.
(pv -n /dev/$partitions | gzip -c >$path/${filename// /_}-${partitions}.img.gz) 2>&1 | while IFS= read -r progress;
do
echo "processing /dev/$partitions currently completed $progress" >/run/log.log
echo $progress | dialog --title "Capturing OS image of $hdd" --gauge " now creating image of HDD $hdd writing $filename Image, please wait...\n\n\n
Processing Partition $i of $totalparts\n\n
This process may take some time to complete\n\n" 13 90 0
mysql -u root -pxxxxxx dbi -h localhost | insert into speed(progress, speed) Values ("$line", "mbits")
done
if I use pv -n command it only returns numeric value of progress on a newline. See below example:
( /data/pv -n /dev/nvme0n1p1 | gzip -c >/run/test.img )
5
9
29
67
100
Above works great for the progress bar, but I want to do update my db with average speed in mbits.
When I run pv command for progress with average speed agrument, progress is updated on the same line instead of print new lines and it breaks my script. See below example.
(pv -rep /dev/nvme0n1p1 | gzip -c >/run/test.img )
[4.9MiB/s] [====> ] 4% ETA 0:00:19
ideal output should be like this.
(pv -rep /dev/nvme0n1p1 | gzip -c >/run/test.img )
[ 4.18MiB/s] [====> ] 14% ETA 0:00:19
[14.49MiB/s] [===========> ] 54% ETA 0:00:19
[24.39MiB/s] [========================> ] 74% ETA 0:00:19
[44.29MiB/s] [===========================> ] 78% ETA 0:00:19
[46.19MiB/s] [=============================> ] 98% ETA 0:00:19
[57.99MiB/s] [==============================>] 100% ETA 0:00:19
I can use AWK, Sed and Grep to format the the required data and use it in my while loop. But how can I get this to work.
If I use pv -F $'%t %r %e\n' I get the desired results. But I cannot use AWK, grep or tr commands. See below example, it returns nothing.
(pv -F $'%t %r %e\n' /dev/nvme0n1p1 | gzip -c >/run/test.img ) 2>&1 | tr -d ':[]'
Also if I don't redirect stderr to stdout, with the same command above, I don't get desired results, see below, using tr -d to delete following characters ":[]" but does not work.
(pv -F $'%t %r %e\n' /dev/nvme0n1p1 | gzip -c >/run/test.img ) | tr -d ':[]'
0:00:01 [25.2MiB/s] ETA 0:00:18
0:00:02 [23.7MiB/s] ETA 0:00:18
0:00:03 [ 100MiB/s] ETA 0:00:07
0:00:04 [ 199MiB/s] ETA 0:00:01
If I use other arguments such as pv -n -r -e, it ignores all other parameters just returns the numeric progress value on a newline.
Maybe there is an alternative to pv that I can use to achieve exactly described above or maybe someone can help with pv command.
user2107349
(147 rep)
Sep 22, 2021, 10:24 AM
• Last activity: Jun 3, 2025, 08:02 PM
3
votes
3
answers
229
views
trap is ignored when dialog is running with custom BASH_XTRACEFD
I have following script ``` #!/bin/bash exec 5> >(logger -t $0) BASH_XTRACEFD="5" set -x trap _reboot INT DIALOG_TITLE="This is fancy dialog title" _reboot() { echo Exiting exit } dialog --title "${DIALOG_TITLE}" --yesno "Welcome to Dialog" 0 0 ``` However when i do CTRL+C, script is exited without...
I have following script
#!/bin/bash
exec 5> >(logger -t $0)
BASH_XTRACEFD="5"
set -x
trap _reboot INT
DIALOG_TITLE="This is fancy dialog title"
_reboot() {
echo Exiting
exit
}
dialog --title "${DIALOG_TITLE}" --yesno "Welcome to Dialog" 0 0
However when i do CTRL+C, script is exited without printing anything.
If i remove either set -x
or BASH_XTRACEFD="5"
it will work fine and trap is caught and _reboot function is executed. But if i leave both in (which i need for debugging purposes) - then trap looses all meaning.
Exit code is 141 which is interesting when i exit with CTRL+C.
If i let the script run it's natural course it will exit with 0
However if i remove either of set -x
or BASH_XTRACEFD="5"
and then CTRL+C
i will exit with 55 then.
This for some reason happens only while dialog is on screen. For example if i do
while true; do
sleep 5
done
And then exit with CTRL+C
trap will be executed.
I need help figuring this thing out.
EDIT:
Might be worth mentioning that bash version is 5.1.16, running on Alpine 3.16
Marko Todoric
(437 rep)
Jul 4, 2022, 11:06 AM
• Last activity: Apr 20, 2025, 09:57 AM
1
votes
2
answers
58
views
bash: take exclusive control of the console/tty
I have a script which implements a simple menu using [dialog][1] (an `ncurses` app for generating TUI widgets). This runs immediately after boot on an Arch-based system. The dialog script works when standalone, but there's a problem when it's run after boot. The boot process writes some delayed outp...
I have a script which implements a simple menu using dialog (an
ncurses
app for generating TUI widgets). This runs immediately after boot on an Arch-based system.
The dialog script works when standalone, but there's a problem when it's run after boot. The boot process writes some delayed output to the console ("Starting network manager script dispatcher service", and possibly a later timeout), and this writes over the menu, and messes up the tty modes. I can fix the tty mode (stty sane
), but I also need to stop the text reaching the console.
Is there some way I can dump any kernel console output from the script?
QF0
(391 rep)
Apr 11, 2025, 10:13 AM
• Last activity: Apr 14, 2025, 06:22 PM
0
votes
2
answers
47
views
Why are control characters added to test.md?
I am using a dialog in order to modify a single value into a file: ``` #!/usr/bin/env bash prompt_and_save() { local file=$1 local message=$2 local value="" # Check if file exists and read value if [ -f "$file" ]; then value=$(cat "$file") fi # Prompt user with dialog value=$(dialog --inputbox "$mes...
I am using a dialog in order to modify a single value into a file:
#!/usr/bin/env bash
prompt_and_save() {
local file=$1
local message=$2
local value=""
# Check if file exists and read value
if [ -f "$file" ]; then
value=$(cat "$file")
fi
# Prompt user with dialog
value=$(dialog --inputbox "$message" 8 50 "$value" 3>&1 1>&2 2>&3)
# Save the value if not empty
if [ ! -z "$value" ]; then
echo "$value" > "$file"
fi
clear
# Return the value
echo "$value"
}
UPSTREAM_VERSION=$(prompt_and_save "VERSION" "Bump the version (or keep it the same)")
clear
NEW_ENTRY="# Version $UPSTREAM_VERSION $DATE"
RELEASE_NOTES=$(cat RELEASE_NOTES)
echo -e "$NEW_ENTRY\n${RELEASE_NOTES}" > test.md
But running this script I get these values in test.md
:
# Version ^[[H^[[2J^[[3J0.2.0
1. Split codebase into multiple files.
2. Use a seperate version file and define built version upon compile.
4. [BUGFIX] If input file is same as output file copy input file into a temporary one.
5. Improved Documentation
6. [BUGFIX] Out of bounds argument parsing
7. [BUGFIX] Values should not be an Argument
How can I remove any control characters from UPSTREAM_VERSION
before echo
it into the file?
Dimitrios Desyllas
(1301 rep)
Mar 27, 2025, 07:53 PM
• Last activity: Apr 1, 2025, 08:12 AM
0
votes
1
answers
44
views
Show dialog gauge while preserving function exit code
This function sends api requests. ```shell api_req() { # req 1 else return 1 echo 33 # req 2 else return 1 echo 66 # req 3 else return 1 echo 100 } ``` This will return 1 when any of the request fails. Now, I want to pass it to **dialog** gauge. Like this, ``` if ! api_req | dialog --gauge "Sending...
This function sends api requests.
api_req() {
# req 1 else return 1
echo 33
# req 2 else return 1
echo 66
# req 3 else return 1
echo 100
}
This will return 1 when any of the request fails.
Now, I want to pass it to **dialog** gauge.
Like this,
if ! api_req | dialog --gauge "Sending requests" -1 -1 0; then
echo "api requests failed!!"
fi
But it can't detect the fail.
I also tried api_req > >(dialog ...)
, but this way the dialog is not shown.
How can I get it working?
decipher
(342 rep)
Nov 7, 2024, 08:28 PM
• Last activity: Nov 8, 2024, 02:13 PM
1
votes
0
answers
95
views
How to get user input in dialog --tailboxbg --gauge?
I have a script I run on a macOS machine, where I wish to show a gauge bar and tail the output from the script itself at the same time. I currently use this command, and it works well: ```` #!/bin/bash TERMINAL_COLS=$(tput cols) TERMINAL_ROWS=$(tput lines) (while true ; do df /Volumes/Backup/ | tail...
I have a script I run on a macOS machine, where I wish to show a gauge bar and tail the output from the script itself at the same time.
I currently use this command, and it works well:
`
#!/bin/bash
TERMINAL_COLS=$(tput cols)
TERMINAL_ROWS=$(tput lines)
(while true ; do
df /Volumes/Backup/ | tail -1 | awk '{print int($3/($3+$4)*100)}'
sleep 1
done | dialog --no-shadow --begin 7 0 \
--tailboxbg /tmp/backup.log $(( $TERMINAL_ROWS - 7 )) $TERMINAL_COLS \
--and-widget --begin 0 0 \
--gauge 'Backup volume usage' 7 $TERMINAL_COLS) &
exec >> /tmp/backup.log
exec 2>&1
...rest of script...
`
This runs dialog
with a tailboxbg
widget, which tails a log file. And it shows the output of the df
loop in a gauge
widget.
Afterwards, the STDOUT and STDERR of the script itself is redirected into the logfile.
Again, this works perfectly well: the script runs as usual, its output is displayed in the tailboxbg
widget, and the gauge
shows the used capacity of the volume as emitted by df
.
The only issue is that dialog
now has no access to the real STDIN (i.e., key presses / terminal) anymore. This means that I cannot use cursor keys to scroll through the tailboxbg
widget, or interact with dialog
in any other way.
Reading the man
page, I do not see a way to get the percentage values to the gauge
widget in any other way. Specifically, it says for the --input-fd
option:
--input-fd fd
Read keyboard input from the given file descriptor. Most dialog
scripts read from the standard input, but the gauge widget reads
a pipe (which is always standard input). [...]
Another idea would be to alias the real STDIN and give it to the tailboxbg
via --input-fd
. The following didn't work though (nothing changed compared to the previous behaviour):
`
...
exec 5<&0
(while true ; do
df /Volumes/Backup/ | tail -1 | awk '{print int($3/($3+$4)*100)}'
sleep 1
done | dialog --input-fd 5 --no-shadow --begin 7 0 --tailboxbg /tmp/backup.log $(( $TERMINAL_ROWS - 7 )) $TERMINAL_COLS --and-widget --begin 0 0 --gauge 'Backup volume usage' 7 $TERMINAL_COLS) &
...
`
The optimum would be if --gauge
allowed to specify an input file instead of always reading STDIN as specified in the man
page, but that's not the way it works.
So... is there a way to forward the "real" STDIN (i.e. user input) to the tailboxbg
widget, but still pipe the output from the fd
loop to the gauge
widget at the same time?
AnoE
(947 rep)
Apr 18, 2024, 11:09 AM
• Last activity: Apr 18, 2024, 11:22 AM
0
votes
1
answers
354
views
Any way to jump to the specific location in file dialog boxes?
Is there a way to enter the location manually? I could copy the location from the right-click menu, but can't paste it from clipboard or jump to desired location fast. Do I really need to dig through the directories each time or there is some better way? Search box just does search in current direct...
Is there a way to enter the location manually? I could copy the location from the right-click menu, but can't paste it from clipboard or jump to desired location fast. Do I really need to dig through the directories each time or there is some better way? Search box just does search in current directory and don't allow me to jump anywhere else...
I am using Ubuntu 22.04 and suppose it's a GTK4 thing to draw file dialogs like this:

Mike
(103 rep)
Mar 11, 2023, 11:54 PM
• Last activity: Mar 6, 2024, 01:50 PM
0
votes
0
answers
36
views
Workaround for applications which use file system dialog that does not enable to open masked folders (beginning with a dot)?
I want to migrate from keepass2 to keepassxc. I am under Debian 12 with XFCE. When I want to open my keypass store located at dot-folder `~/.keepass` , the file system dialog of keepassxc does not enable to input a path, it is just clicking on lists and it does not show dot-folders (which names star...
I want to migrate from keepass2 to keepassxc. I am under Debian 12 with XFCE. When I want to open my keypass store located at dot-folder
~/.keepass
, the file system dialog of keepassxc does not enable to input a path, it is just clicking on lists and it does not show dot-folders (which names start with a dot). I could see this problem with other apps.
Is it an app problem or a XFCE standard dialog problem or something else?
I could move my keepass store in a non masked folder, but I wonder how I can solve or workaround this problem without moving my files?
lalebarde
(275 rep)
Jan 13, 2024, 11:47 AM
3
votes
2
answers
30791
views
dialog menu to display files and select one of them
I want to display all the files under `/home` directory in menu, and select only one of them. Then the script will print the full path of the selected file. I have created the following script. This script only displays the files in the dialog box menu. #!/bin/bash dialog --title "List file of direc...
I want to display all the files under
/home
directory in menu, and select only one of them. Then the script will print the full path of the selected file.
I have created the following script. This script only displays the files in the dialog box menu.
#!/bin/bash
dialog --title "List file of directory /home" --msgbox "$(ls /home )" 100 100
maihabunash
(7231 rep)
Sep 15, 2014, 05:55 AM
• Last activity: Jan 4, 2024, 08:03 PM
2
votes
1
answers
1182
views
What is the practical consequence of the message "unable to initialize frontend: Dialog" when installing packages in a non-standard shell?
When I install some software packages from Emacs in a non-interactive shell, say from an `org-babel` file some of the packages result in the message below: ```text debconf: unable to initialize frontend: Dialog debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or wit...
When I install some software packages from Emacs in a non-interactive shell, say from an
org-babel
file some of the packages result in the message below:
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
I know that in the case of mysql for instance it is to prompt for the root password, or some other stuff which the user's preferences or settings are sought.
I take it that in such cases the installer may use some default settings and continue.
So my main concerns are:
1. Can the consequences be that bad?
2. Are there some kind of response files related to each package that can be passed to the installer or some default files at some preset locations that can be used for this purpose?
vfclists
(7909 rep)
Nov 27, 2023, 08:31 PM
• Last activity: Nov 28, 2023, 01:54 PM
3
votes
1
answers
1694
views
Can I somehow use a different file picker dialog than GNOME/GTK's own?
I use the Cinnamon desktop environment on my Devuan Daedalus GNU/Linux machine. I like Cinnamon well enough (better than the other DEs available obviously), but - I'm not a fan of GTk, and most especially, the GTk filer picker dialog is absolutely _horrid_. I find it so inconvenient! ... instead of...
I use the Cinnamon desktop environment on my Devuan Daedalus GNU/Linux machine. I like Cinnamon well enough (better than the other DEs available obviously), but - I'm not a fan of GTk, and most especially, the GTk filer picker dialog is absolutely _horrid_. I find it so inconvenient! ... instead of ranting, though, let me be practical: Is there someway I could replace it with something else? e.g. some kind of plugin or LD_PRELOAD trick?
einpoklum
(10753 rep)
Apr 24, 2023, 06:34 PM
• Last activity: Jul 11, 2023, 08:38 PM
-1
votes
1
answers
2274
views
bash dialog prevent exit
I have a bash script with dialog `--checklist` This comes with an `OK` and `cancel` button. When I press `cancel`, the script exits and returns to shell. How do I remove the `cancel` button or prevent the user to enter shell? ``` #!/bin/bash set -e rm -f /tmp/output rm -f /oke/harddisk rm -f /tmp/hd...
I have a bash script with dialog
--checklist
This comes with an OK
and cancel
button.
When I press cancel
, the script exits and returns to shell.
How do I remove the cancel
button or prevent the user to enter shell?
#!/bin/bash
set -e
rm -f /tmp/output
rm -f /oke/harddisk
rm -f /tmp/hdbron1
rm -f /tmp/hdbron2
output=echo /tmp/output
hd1=/tmp/hdbron1
hd2=/tmp/hdbron2
hd3=/tmp/output
#lsblk -d -e 11,7 -dio size,model | sed 1d | awk '$1=$1' | tr " " "_" | sed -e "s/$/ \/\ /"> /tmp/hdbron2
lsblk -d -e 11,7 -dio size,model | awk '!($1 ~ "M")'| sed 1d | awk '$1=$1' | tr " " "_" | sed -e "s/$/ \/\ /"> /tmp/hdbron2
lsblk -d -e 11,7 | grep "disk" | awk '!($4 ~ "M")'| awk '{print $1}' > /tmp/hdbron1
paste $hd1 $hd2 | paste > /tmp/output
dialog --checklist "Selecteer doel schijf:" 60 90 60 \
$(cat /tmp/output) 2>/oke/harddisk
wjp79
(107 rep)
Oct 8, 2019, 02:07 PM
• Last activity: Jun 14, 2023, 01:02 AM
3
votes
2
answers
1634
views
Bash script function that changes the value of a variable
I'd like to make a function for a BASH script that changes the value of one of its arguments, that is a variable. The function that I did is: chck_rgx () { # Checks that the given name for a user/group fulfills the regex. The function's parameters are # * $1: kind of name to check: username, hostnam...
I'd like to make a function for a BASH script that changes the value of one of its arguments, that is a variable. The function that I did is:
chck_rgx () { # Checks that the given name for a user/group fulfills the regex. The function's parameters are
# * $1: kind of name to check: username, hostname, etc.
# * $2: variable whose value to check if meets the requirements.
local rgx_hostname='^[a-z][a-zA-Z0-9_-]+$' ;
local rgx_inputbox_hostname="The hostname you just submitted isn't a valid name. Try with another name."
local rgx_username='^[a-z][a-z0-9_-]+$' ;
local rgx_inputbox_username="The username you just submitted isn't a valid name. Try with another name." ;
eval rgx_name="\$rgx_$1" ;
eval rgx_inputbox="\$rgx_inputbox_$1" ;
eval name_ch="\$$2" ;
while [[ ! $name_ch =~ $rgx_name ]] ; do
dialog --backtitle "$backtitle_var" \
--title "Wrong $1 submitted" --clear \
--inputbox "$rgx_inputbox" 0 0 2> name-ch ;
name_ch=$(cat name-ch) ;
rm name-ch ;
done
chckd_var="$name_ch" ;
}
Then in some part of the script there is a dialog box asking you to insert a name and then this function checks if the given name is a valid name. For instance,
dialog --backtitle "$backtitle_var" \
--title "Submit the username" --clear \
--inputbox "Which username do you want?" 0 0 2> user-name ;
user_name=$(cat user-name) ;
chck_rgx username user_name ;
user_name=$chckd_var ;
The problem I have is that the "output" of my function, the value I have now, is not in the same variable I used in the first place. I have to assign the value of the "output" of my function ($chckd_var) to the variable that I inserted as an argument in the function (user_name). What I want to do is that the function changes the value of the global variable user_name (or whatever other variable).
Also, I'd like to know if there's a way to get the output of a dialog inputbox directly in a variable; not in a file.
I'm fairly new to BASH scripts, so perhaps the answer is quite simple. Anyway, I've been looking for this on the web and haven't found the answer.
ctafur
(59 rep)
Jul 28, 2015, 09:48 PM
• Last activity: Apr 4, 2023, 12:00 PM
2
votes
1
answers
1282
views
How to "not clear" the screen when using dialog?
`dialog` is a great tool but I can't find a way to use it in a bash script where it would NOT clear the screen beforehand. I know this is possible if I use `--keep-window` in conjunction with `--and-widget` but in this case I cannot process the user input before displaying the next dialog. Is it pos...
dialog
is a great tool but I can't find a way to use it in a bash script where it would NOT clear the screen beforehand.
I know this is possible if I use --keep-window
in conjunction with --and-widget
but in this case I cannot process the user input before displaying the next dialog.
Is it possible to launch a dialog
command and having it draw its window without clearing the screen ? Is there some trick I'm not aware of ?
**EDIT** (clarification):
Here's a simplified example script of what I'd like to achieve (no, I'm not trying to write a game in bash ;) ): the user input from the first dialog is important to the script and is saved in the variable selection
The second dialog should then be displayed in front of the first one. But calling dialog
automatically clears the screen (and so the first dialog has disappeared)
#!/bin/bash
# selection will contain the "tag" of the option selected, either 1, 2 or 3
selection=$(dialog --output-fd 1 --menu "Which cup will you choose ?" 0 0 0 1 "A simple wooden bowl" 2 "A golden jeweled cup" 3 "A plastic goblet")
# and now a second dialog that I'd like to show in front of the first one without clearing the screen
case $selection in
1)
dialog --msgbox "You have chosen ... wisely." 0 0
;;
2)
dialog --msgbox "You chose ... poorly" 0 0
;;
3)
dialog --msgbox "You must be kidding right ?" 0 0
;;
*)
dialog --msgbox "You have to choose one !" 0 0
;;
esac
fvlinden
(129 rep)
Feb 8, 2022, 10:30 AM
• Last activity: Feb 17, 2023, 02:58 PM
4
votes
1
answers
714
views
How can I paste full path strings in the GNOME File Selection Dialog on RHEL?
I have a remote RHEL machine which I use via X11. On that machine when I open a new file in, say, VS Code or in the Firefox browser (both apps are on teh remote machine), then I get teh following File Selection Dialog: [![File Selection Dialog][1]][1] In this Dialog I get only to teh desired loactio...
I have a remote RHEL machine which I use via X11. On that machine when I open a new file in, say, VS Code or in the Firefox browser (both apps are on teh remote machine), then I get teh following File Selection Dialog:
In this Dialog I get only to teh desired loaction by mutiple clicks on teh various path elements. However very often I have a path string like

/opt/servers/tomcat/apache-tomcat-8.5.78/conf/server.xml
in the clipboard which I just could paste to get to the desired location.
Are File Selection Dialogs available which can use a full path string and how do I hook them up to the RHEL system?
### Some more details:
| Info | Value |
| --- | --- |
| **Remote OS:** | Red Hat Enterprise Linux 8.3 |
| **Local X11 "server":** | MobaXterm on Windows |
halloleo
(649 rep)
Dec 6, 2022, 04:26 AM
• Last activity: Dec 6, 2022, 05:14 AM
1
votes
3
answers
359
views
Get stderr after redirecting output to dialog gauge
I am using a python file to scrape a link, but to do that it takes some time, it prints `33`, `66` and `100` normally and print the link to stderr using `sys.write.stderr(var)` Now, I want to run this command `python file.py | dialog --gauge "Doing stuffs" 10 35 0` and want to pipe the stdout(33, 66...
I am using a python file to scrape a link, but to do that it takes some time, it prints
33
, 66
and 100
normally and print the link to stderr using sys.write.stderr(var)
Now, I want to run this command python file.py | dialog --gauge "Doing stuffs" 10 35 0
and want to pipe the stdout(33, 66, 100 for updating percentage) to gauge and get the sterr to a variable.
{
python3 file.py 2>&3 | dialog --gauge "Doing stuffs" 10 35 0;
} 3>&1
this command runs dialog correctly and then print the stderr, but I can't take its output unless It is made to run in subshell. But doing so will make the dialog disappear.
decipher
(342 rep)
Oct 31, 2022, 04:16 PM
• Last activity: Nov 1, 2022, 05:57 PM
1
votes
0
answers
177
views
is there a list of minimum term capabilities for dialog(ncurses)?
I'm trying to write some code using the ncurses dialog library (available everywhere, [source mirror is here][1]) and I'm trying to decide dynamically in code whether to use dialog or just print to stderr and prompt with getc() based on whether stdin/out/err are hooked up to char block devices, ttys...
I'm trying to write some code using the ncurses dialog library (available everywhere, source mirror is here ) and I'm trying to decide dynamically in code whether to use dialog or just print to stderr and prompt with getc() based on whether stdin/out/err are hooked up to char block devices, ttys, and what termcaps they have. I've stolen some code from less that seems pretty reliable at detecting whether it can render properly, and it looks for termcaps
ce
,cd
,cl
and either cm
, or ho
and ll
, and either al
or sr
, otherwise it switches to dumb mode. But less has (much?) lower requirements than dialog, presumably (I just need yesno boxes, at least). I'm kind of surprised there's no check for caps in dialog or in ncurses, and no way to just ask if the terminal can handle things, or fail initscr if it doesn't have the caps? dialog on an emacs shell (not on ansi-term, it works fine there obvs) just spews nonsense text because it's a dumb terminal (same if you export TERM=dumb
in a normal xterm), so there's clearly no capabilities checking going on here.
I'm not a unix programmer most of the time, so is there some standard way of doing this that's robust? It's odd to me that this isn't a thing that's easy to check for.
I can obviously grovel through the dialog yesno code and try to record all the ncurses stuff it calls, but that's a pain, so I'm hoping I'm just failing to find a clear terminal capabilities requirements list somewhere.
**Update:** so I decided to mess around with making my own custom terminfo entry to test how minimal I could go and still get the yesno dialog, and it's pretty minimal, so the less tests are basically good. It was hard to figure out how to do this, so here's a brief summary for other folks from THE FUTURE:
- Here are the termcap definitions you'll need to figure things out; you can work directly with terminfo definitions and skip a couple steps, but old software like less are using the termcap versions and so it'll be easier to just work in that space.
- Assuming you've got an ncurses app that runs on your current terminal (or dialog --title Hi --yesno There 0 0
), figure out what your TERM envvar is. I'm working in screen and emacs ansi-term, so they're screen
and eterm-color
in my tests, and of course dumb
- Dump the one you want to muck with (that you're running the tests with because you want your new one to be a subset of a working one) using infocmp eterm > eterm2.info
, this gives you the info version to work with.
- Convert it to cap with infotocap eterm2.info > eterm2.cap
- Look inside, and cut it way down, like here's my minimal cap file that will just barely run less without warnings:
# hacked eterm for testing dialog
eterm2|gnu emacs term.el terminal emulation:\
:am:mi:xn:\
:co#80:li#24:\
:ce=\E[K:cd=\E[J:cl=\E[H\E[J:\
:ho=\E[H:\
:cm=\E[%i%d;%dH:\
:al=\E[L:
- Notice I changed the name at the beginning to eterm2 as well.
- Convert that back to info with captoinfo eterm2.cap > eterm2.info
- mkdir infodb
to make the local dir where you're going to compile this test info.
- export TERMINFO=$(pwd)/infodb
to tell termcap/terminfo where to find it
- tic -D
should output that local dir first
- tic -s eterm2.info
will compile it to that dir
- export TERM=eterm2
to set your new hacked terminal
- Run your ncurses app or dialog --title Hi --yesno There 0 0
and it should show up in all its black and white simple glory.
- You can play around with adding other commands back in to see what changes, but when you're done, rm -rf infodb
, export TERMINFO=
, and export TERM=
and make sure things run right.
**Update2:** Here is the code I ended up with which seems to work in all my tests:
if(TermMode == TERM_UNINITIALIZED) {
struct stat s;
if((isatty(STDOUT_FILENO) && (fstat(STDOUT_FILENO,&s) == 0) && S_ISCHR(s.st_mode)) &&
(isatty( STDIN_FILENO) && (fstat( STDIN_FILENO,&s) == 0) && S_ISCHR(s.st_mode)))
{
// both stdout and stdin are char block device ttys, now check termcaps
// mostly stolen from the gnu less source code, since it seems robust
// https://github.com/gwsw/less/blob/22e4af5cccbfab633000c7d610f868a868ad6e1a/screen.c#L1280
char termbuf;
char const* term = getenv("TERM");
int const TGETENT_OK = 1;
if(tgetent(termbuf,term) == TGETENT_OK) {
char sbuf;
char* sp = sbuf;
char* sr = 0;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
// ce ce cl are required
if((sr = tgetstr("ce",&sp)) && *sr && // eol clear
(sr = tgetstr("cd",&sp)) && *sr && // eos clear
(sr = tgetstr("cl",&sp)) && *sr) // screen clear
{
// cm or (ho and ll)
if(((sr = tgetstr("cm",&sp)) && *sr) || // cursor move
(((sr = tgetstr("ho",&sp)) && *sr) && // home
((sr = tgetstr("ll",&sp)) && *sr))) // lower left
{
// al or sr
if(((sr = tgetstr("al",&sp)) && *sr) || // add line
((sr = tgetstr("sr",&sp)) && *sr)) // scroll reverse
{
// we've got what we need for ncurses dialog!
TermMode = TERM_DIALOG;
goto term_detected;
}
}
}
#pragma GCC diagnostic pop
}
// we're at least connected to a tty
TermMode = TERM_STDIO;
} else {
// no interaction, so gotta just abort
TermMode = TERM_ABORT;
}
term_detected:
;
}
Anyway, it would still be very nice to know what the minimal termcaps are, but at the very least the ones listed above for less work, so I'm going to use those.
Thanks,
Chris
Chris Hecker
(19 rep)
Oct 22, 2022, 02:49 AM
• Last activity: Oct 23, 2022, 12:16 AM
0
votes
1
answers
529
views
how to make GNOME Dialog boxes
So I have played around with Zenity on a few Linux distros, but I haven't ever been able to achieve this effect: [![enter image description here][1]][1] So My question is, how do I create one of these dialog boxes? I would like to have customizable title, body, and buttons. I am on Fedora 35, if it...
So I have played around with Zenity on a few Linux distros, but I haven't ever been able to achieve this effect:
So My question is, how do I create one of these dialog boxes? I would like to have customizable title, body, and buttons. I am on Fedora 35, if it helps.

Zany_Zachary1
(133 rep)
Mar 25, 2022, 06:32 PM
• Last activity: Mar 25, 2022, 06:45 PM
Showing page 1 of 20 total questions