views:

287

answers:

2

I have a cron entry that runs a script at a certain time each day. The script sets the DISPLAY to :0 and launches a program for the user to run (this is a single-user desktop). I want to change this so that the user first sees a dialog box so he can indicate whether he wants to run the program.

I'm using Ubuntu with Gnome. Is there some kind of dialog box command that can return whether OK or Cancel was clicked? Or is there some other way to get this effect?

+6  A: 

You could use Zenity. It allows you to use GTK dialogs, and I think the yes/no ones just store their value in $?. You can use:

if zenity --question --text="Are you sure?"; then
    sudo rm -rf / # kidding!
fi

Just like usual.

Lucas Jones
+4  A: 

zenity --question

cube