PDA

View Full Version : ask the user



cazz
June 18th, 2009, 07:35 AM
Hi

I have a script that run partimage so it restore a backup

but I like to ask the user if that person is sure that person want to restore the backup.

maybe even have a number that random so that person have to write to make sure that person dont press Y by mistake

moma
June 18th, 2009, 09:22 AM
If your script can have a GUI, then use Zenity... (http://live.gnome.org/Zenity) or Dialog... (http://www.linuxjournal.com/article/2460).
Zenity's manual: http://library.gnome.org/users/zenity/stable/
Zenity requires GNOME/GTK but I think the Dialog is much simpler, it only needs Xorg/Xlib GUI system.

If you cannot have a GUI then use the bash's read command.
http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_08_02.html

cazz
June 18th, 2009, 10:17 AM
Thanks :)

nvteighen
June 18th, 2009, 02:54 PM
...
Zenity requires GNOME/GTK but I think the Dialog is much simpler, it only needs Xorg/Xlib GUI system.


Dialog doesn't use Xlib, so you can use it even in console :)