PDA

View Full Version : [SOLVED] [bash] Checking for a directory in root



AntumDeluge
May 1st, 2010, 02:05 AM
I'm trying to check if a directory exists under root, but if I don't have root permissions, it returns as false.


if [ -d "/root/Desktop" ]; then echo "hello world"; fi
How do I check for a root directory if I don't have permission? Or, how do I use my sudoer permissions to check for a directory?

tookyourtime
May 1st, 2010, 03:54 AM
What happens if just just run the script with


sudo ./testscript
?

AntumDeluge
May 1st, 2010, 04:24 AM
You're totally right. For some reason I was thinking that I wanted to run this script without sudo, but now that I think it through, that is what I want to do. Thanks.