Re: Why doesn't this sudo script using zenity work??



Thanks Stefano;

It now works. 

On Sat, 2006-12-02 at 20:16 +0100, Stefano Sabatini wrote:
> Hi William.
> 
> On Friday 2006-12-01 11:15:33 -0500, William Case wrote:
> > Tried:

> > Nothing shows up on my desktop.
> 
> How did you try it? 

Wrote it as a script in a file called RootBrowser.  Changed the
permissions to executable by bill (as usual).  I have bill's PATH
including $HOME/.gnome2/nautilus-scripts.  Tried .RootBrowser from the
command line.  It worked but gave me the last two lines as returns for
the gterm.

Tried it as a single command line. It worked as above.
> If you wrote it in a file and then launched it
> get sure to put in the first line
> #! /usr/bin/bash
I did that.

> and to change permission of the file (it has to be executable at least
> by you).
> 
I did that.
> I'm trying this script and it works both as a script launched from
> gnome-terminal and when it's called by a gnome-panel launcher:
> 
> #! /bin/bash
> 
> # this forces the password typing, even in the case the sudo timeout has
> # not yet expired
> sudo -k
Didn't use sudo -k but it makes sense as a precaution
> 
> zenity --entry --title="Browse files as root" --text="Enter your password:" --hide-text \
> | sudo -S nautilus --no-desktop --browser 1> /dev/null 2> /dev/null
> 
Knew I probably wanted to background or /dev/null return variabless 1 &
2 above but wasn't sure how to go about it.  Had read some manuals about
file descriptors but have never need to use them, so didn't know how to
use 1 & 2 to send the lines /dev/null.  Tried things that were far too
complex that obviously didn't work.  So, thanks that was the solution I
needed.

> if [ "$?" != 0 ]; then
>     zenity --error --text="Sorry, bad password"
>     return 1
> fi
Essentially did that.  Knew to do it but hadn't written it yet trying to
keep the number of possible complications down until the rest worked.


> > What do I do with these two lines?
> 
> Anything you want to do with them ;-).  If you don't like this output
> you can simply send it to /dev/null (as in the above script). sudo
> prints the "password:" prompt on stderr (file descriptor number 2),
> nautilus writes on both stderr and stdin (file descriptor number
> 1). If you are running the script through a launcher the output will
> be happily ignored.
> 
Thanks for the explanation.  I'll go back and 'man' for your kind of
comments if I have further questions.

> HTH
> 
> Ciao!
> _______________________________________________
> gnome-list mailing list
> gnome-list gnome org
> http://mail.gnome.org/mailman/listinfo/gnome-list
-- 
Regards Bill




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]