I have been teaching myself bash scripting and have run into an issue. I have written a script to take input from the user, using the 'read' command, and make that input a variable to use later in the script. The script works, but….
I would like to be able to get it setup using 'dialog'. I found out that
'dialog –inputbox' will direct the output to 'stderr' and in order to get that input as a variable you have to direct it to a file and then retrieve it. The code I found to explain this is:
#!/bin/bash dialog --inputbox \ "What is your username?" 0 0 2> /tmp/inputbox.tmp.$$ retval=$? input=`cat /tmp/inputbox.tmp.$$` rm -f /tmp/inputbox.tmp.$$ case $retval in 0) echo "Your username is '$input'";; 1) echo "Cancel pressed.";; esac
I see that it is sending the sdterr to the /tmp/inputbox.tmp.$$ with 2>, but the output file looks like 'inputbox.tmp.21661'. When I try and cat the file it gives me an error. So I am still unable to get the user input from the –inputbox as a variable.
echo " What app would you like to remove? " read dead_app sudo apt-get remove --purge $dead_app
So as you can see it is a basic script. Is it even possible to get the variable as a word from