PDA

View Full Version : [SOLVED] Bash: How can I use the Zenity progress window and keep the application's text output



alexandrexavier
August 7th, 2016, 09:47 PM
Hi everyone,

I have this code:


choice=$(top -n 3 | zenity --progress --pulsate --auto-close)

When it's done, the $choice variable is empty. Is there a way to keep the application's text output when using Zenity's progress window?

Thanks,
Alex

alexandrexavier
August 7th, 2016, 10:03 PM
Found by myself after struggling with the "tee" command.


OUTPUT="$(gksudo apt-get install $choice | tee >(zenity --progress --pulsate --auto-close))"

halogen2
August 7th, 2016, 10:03 PM
Seems zenity is just eating the stdout stream you're giving it. Work around that using a temporary file -

tmp_store=$(mktemp)
top -n 3 | tee "$tmp_store" | zenity --progress --pulsate --auto-close
choice="$(cat $tmp_store)"
rm -fv $tmp_store

alexandrexavier
August 7th, 2016, 10:04 PM
Thanks.