While trying something similar in a bash script I made this snippet:
#!/bin/bash
your_animal="fishies"
zenity --info --text="Do you like to eat $your_animal?"
if zenity --entry --title="Root Partition" \
--text="what is your favorite animal"
then your_animal=$?
else exit
fi
#echo $your_animal
zenity --info --text="Do you like to eat $your_animal?"
exit
which prints
Do you like to eat fishies?
Do you like to eat 0?
also maybe we could make this into wiki for the same problem in other languages, like perl.
$?is the status of the last executed command. In your case, it’s going to be 0, so the displayed text"Do you like to eat 0?"is correct.To get the output of a command, use
or
Try this: