LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 06-06-2005, 06:03 PM   #1
cantabile
LQ Newbie
 
Registered: Jan 2004
Posts: 28

Rep: Reputation: 15
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.
 
Old 06-06-2005, 06:21 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967
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.
 
Old 06-06-2005, 06:21 PM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967
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
 
Old 06-06-2005, 06:31 PM   #4
cantabile
LQ Newbie
 
Registered: Jan 2004
Posts: 28

Original Poster
Rep: Reputation: 15
Well, works like a charm !
Nice. Thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script problem fatbastard spice Linux - General 2 08-24-2005 03:15 AM
bash script problem GATTACA Programming 3 06-13-2005 10:59 AM
bash script problem cookie_ie Programming 3 03-23-2005 03:19 PM
bash script problem sorry99 Programming 2 09-20-2004 10:02 AM
Bash script problem kalleanka Programming 2 01-30-2004 12:59 PM


All times are GMT -5. The time now is 04:03 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration