permission script

~TraydenT~ traydent at gmail.com
Sun Oct 25 16:47:49 UTC 2009


Le 25/10/2009 17:42, Eugeneapolinary Ju a écrit :
> I just wrote a little script, that will echo a message to the user, if 
> it doesn't have enough permission:
>
> $ if ! [ "$(env LC_MESSAGES=C ifconfig wlan0 down | grep -i denied)" 
> == "" ]; then echo "no permission"; fi
> SIOCSIFFLAGS: Permission denied
> $ sudo su
> [sudo] password for USER:
> # if ! [ "$(env LC_MESSAGES=C ifconfig wlan0 down | grep -i denied)" 
> == "" ]; then echo "no permission"; fi
> #
>
> but it won't works
>
> why?
>
>
The ifconfig command returns the denied message on the standard error, 
not on stdout. To find if it was denied, you way redirect stderr on 
stdout (by adding 2>&1 to the command line ), or check the return code 
of the ifconfig command.




More information about the ubuntu-users mailing list