LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Problem with this bash script (https://www.linuxquestions.org/questions/programming-9/problem-with-this-bash-script-330990/)

cantabile 06-06-2005 05:03 PM

Problem with this bash script
 
Hi,
I have a problem with the following Bash script I found while surfing :

Code:

#!/bin/bash
name=`dialog --backtitle "Hello Bash script"\
                --title " The question "\
                --inputbox " what's your first name : " 0 0 2>&1`
if [ $? = 0 ]; then
        dialog --title "Hello Bash script"\
        --msgbox "\nHi, $name !" 10 30
fi
exit 0



When I run it, the fisrt dialog doesn't show up and, if I type something in the console, the second box shows a lot of garbage.

So my question is : is it possible to get user input this way or is there another preferred way ?


Thanks for your help. :)

acid_kewpie 06-06-2005 05:21 PM

another thing i learnt about today then... dialog!

seems there have been standard setting changes, add the option --stdout to the first command and it should all be ok. was for me. if you want an X way to do this, look at Gnome's zenity utility.

acid_kewpie 06-06-2005 05:21 PM

Code:

#!/bin/bash
name=`dialog --stdout --backtitle "Hello Bash script"\
        --title " The question "\
        --inputbox " what's your first name : " 0 0 2>&1`
if [ $? = 0 ]; then
dialog --title "Hello Bash script"\
        --msgbox "\nHi, $name !" 10 30
fi
exit 0

btw

cantabile 06-06-2005 05:31 PM

Well, works like a charm !
Nice. Thanks. :)


All times are GMT -5. The time now is 05:14 PM.