# dialog input box



## Wolfi83 (Sep 9, 2011)

hi,

i want to set a dialog input box in my shells like on linux.
actually i "read" all important informations via read -p "name" NAME.
now i want to have a dialog input box in it like the sysinstall box where i can input a ftp-address i hope you know what i mean my english isnt good at all .. 

via bash this works



```
dialog --clear --inputbox "Input your password" 10 60 2> password.tml  

clear       
echo "Password: `cat password.tmp`"

exit 0
```

but i dont wont to save these informations in the .tmp file


----------



## graudeejs (Sep 9, 2011)

What is your goal?


----------



## kpa (Sep 9, 2011)

Are you using csh or tcsh as your shell?

This works if I run it in /bin/sh shell:

`$ dialog --inputbox "Enter your name" 10 60 2>temp.txt`


----------



## Wolfi83 (Sep 9, 2011)

graudeejs said:
			
		

> What is your goal?



It is just beautiful, but i dont want that the inputbox save the entering text in a "temp" file, just like read, so i want that the dialog save the text in the cache, like "read"



			
				kpa said:
			
		

> Are you using csh or tcsh as your shell?
> 
> This works if I run it in /bin/sh shell:
> 
> `$ dialog --inputbox "Enter your name" 10 60 2>temp.txt`



Yes, this runs in /bin/sh shell.


----------



## graudeejs (Sep 9, 2011)

Wolfi83 said:
			
		

> It is just beautiful, but i dont want that the inputbox save the entering text in a "temp" file, just like read, so i want that the dialog save the text in the cache, like "read"



I mean, where are you going to use it?


----------



## Wolfi83 (Sep 9, 2011)

graudeejs said:
			
		

> I mean, where are you going to use it?



If i ask a question in a shell like:

Please enter your mysql password
please enter the full pfad
please enter the ftp pfad

these things ..


----------



## DutchDaemon (Sep 9, 2011)

So, just read the info from the file into a variable.


```
choice=$( cat temp.txt )
```

Now you can manipulate it any way you like by using the variable ${choice}.


----------



## Wolfi83 (Sep 9, 2011)

DutchDaemon said:
			
		

> So, just read the info from the file into a variable.
> 
> 
> ```
> ...



If i have 3 dialogs and i write the 3 informations in a file how i can get the information in line 1, line 2 and line 3?
so if i ask 

```
"enter mysql user" 2> mysql.tmp
"enter mysql pass" 2> mysql.tmp
"enter mysql host" 2> mysql.tmp
```


----------



## DutchDaemon (Sep 9, 2011)

Really? You think you're stuck on using one file name for everything?


```
"enter mysql user" 2> mysqluser.tmp
"enter mysql pass" 2> mysqlpass.tmp
"enter mysql host" 2> mysqlhost.tmp
```


```
mysqluser=$( cat mysqluser.tmp )
mysqlpass=$( cat mysqlpass.tmp )
mysqlhost=$( cat mysqlhost.tmp )
```


----------



## Wolfi83 (Sep 9, 2011)

DutchDaemon said:
			
		

> Really? You think you're stuck on using one file name for everything?
> 
> 
> ```
> ...



This way is of couse ok, too lol i dont get this idea :stud


----------



## Wolfi83 (Sep 9, 2011)

hi,

how can i get the password in a query like this now?


```
PASS="mysqlpass"
USER=$( cat mysqluser.tmp )
HOST=$( cat mysqlhost.tmp )
NEWPASS=$( cat mysqluserpass.tmp )

mysql -u root -p$PASS -e "GRANT ALL PRIVILEGES ON *.* TO '$USER'@'$HOST' IDENTIFIED BY '$NEWPASS';"
```

$PASS is the actually password of user root.

Thanks a lot


----------



## Wolfi83 (Sep 9, 2011)

Sorry i forgot to say that this code over my post do not work .


----------



## Wolfi83 (Sep 9, 2011)

Issue solved.


----------



## Wolfi83 (Sep 10, 2011)

One last question!!

If i enter a password in the dialog, i want that the password is hidden.
So not like "Please enter your password" - "mysqlpassword"
Like "Please enter your password" - "*********"

Thanks


----------



## DutchDaemon (Sep 10, 2011)

dialog in FreeBSD 9 has the option --passwordbox. I don't see it in FreeBSD 8 yet.


```
â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
â”‚ 10               â”‚
â”‚ â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â” â”‚
â”‚ â”‚              â”‚ â”‚
â”‚ â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜ â”‚
â”‚                  â”‚
â”‚                  â”‚
â”œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¤
â”‚<  OK  > <Cancel> â”‚
â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
```

It doesn't print anything (not even **).


----------



## DutchDaemon (Sep 10, 2011)

Or you'll just have to leave dialog alone for the password entry, and use a bit of shell script. e.g.


```
#!/bin/sh
echo -n "Enter password: "
stty -echo
read passwd
stty echo
```

The ${passwd} variable will then contain the password, but it will not print on screen.


----------



## Wolfi83 (Sep 10, 2011)

DutchDaemon said:
			
		

> Or you'll just have to leave dialog alone for the password entry, and use a bit of shell script. e.g.
> 
> 
> ```
> ...



Thanks, that helped me a lot!


----------



## freethread (Sep 10, 2011)

dialog in FreeBSD 9.0 is the same as devel/cdialog for previous versions. In cdialog sample directory (if I remember are in /usr/local/share/doc/cdialog or in the nearby, there are examples that use forms to ask in one dialog instance the user login name, the password and some other info. If samples are not where I said, download cdialog sources (formely dialog) and look inside samples directory.


----------

