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



Hi William.

On Friday 2006-12-01 11:15:33 -0500, William Case wrote:
> Tried:
> zenity --entry \
>        --title="Browse files as root" \
>        --text="Enter your _password:" \
>        --entry-text "" \
>        --hide-text | sudo -S nautilus --no-desktop --browser
> 
> Nothing shows up on my desktop.

How did you try it? If you wrote it in a file and then launched it
get sure to put in the first line
#! /usr/bin/bash
and to change permission of the file (it has to be executable at least
by you).

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

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

if [ "$?" != 0 ]; then
    zenity --error --text="Sorry, bad password"
    return 1
fi

> 
> Tried it again in gTerminal and got:
> my file browser in root plus:
> 
> Password:   
> [Entered through zenity ==> File Browser plus in stdout / stderror?]
> Initializing nautilus-search-tool extension
> Initializing nautilus-open-terminal extension
> 
> 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.

HTH

Ciao!



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