about -w


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting about -w
# 1  
Old 05-14-2012
about -w

-w "filename"

is suppose to return 0 if the file got write permission and 1 if not right?

for some reason... when i test it, it keep returning 1 even after i set full 777 permission to that file/directory?

the directory will become /path/path2/path3
Code:
directory = `dirname /path1/path2/path3/file.txt`

if [ -w "$directory" ]
then
   echo $?
else
   echo $?
fi

# 2  
Old 05-14-2012
Code:
directory=`dirname /path1/path2/path3/file.txt`

Change this line .. no spaces... Scripting does not like spaces
Likes to be close .. while with variable. Smilie
This User Gave Thanks to chakrapani For This Post:
# 3  
Old 05-14-2012
ah right, that's true haha..

tried that doesnt work too, still showing i dont have permission... even tho its showing that everyone got full drwxrwxrwx permission...
# 4  
Old 05-14-2012
Please post the output from:
Code:
ls -ald /path1/path2/path3
ls -lad /path1/path2/path3/file.txt
id

# 5  
Old 05-14-2012
Does you system have acl's ie.,
in ls -l output do you see
Code:
drwxrwxrwx+

some character after the perms?

What OS and shell are you using?
This User Gave Thanks to jim mcnamara For This Post:
# 6  
Old 05-14-2012
ok now that's funny.... it shows no such file or directory..., dont think i got typo..

using bourne shell, unix

yeh it's showing drwxrwxrwx
# 7  
Old 05-14-2012
Please can you type the commands which you are asked to type and post the full output, not just the bit which you think is relevant. Also, if you get an error message please post what you typed and the complete and exact matching error message.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question