如何检查目录是否具有读/写权限 [英] How to check a directory has a read/write permission

查看:140
本文介绍了如何检查目录是否具有读/写权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个如图所示的目录

I have a directory as shown

d-wx--x--x 2 bcheudev bcheudev  4096 Jun 18 06:16 test

显示目录没有读取权限.

which shows the directory does not have read permission.

但是当我通过shell脚本检查相同内容时,由于dir test具有读取权限,因此给出结果.

But when i check the same through shell script it's giving result as dir test has read permission.

export IN_DIR=$MMHOME/test   
if [ -d ${IN_DIR}  ]    
then    
   if [ ! -r ${IN_DIR} ]    
   then    
      echo "${IN_DIR} Directory is not readable.">>$log_name    
      exit 255   
   fi    
else    
   echo "${IN_DIR} Directory does not Exists.">>$log_name
   exit 255    
fi

如果不行,排在第二位.

inside second if it's not going.

请帮助

推荐答案

请记住,root将始终具有读取权限.

Remember that root will always have read permissions.

这篇关于如何检查目录是否具有读/写权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆