|
|
6#

楼主 |
发表于 2009-12-15 21:52:37
|
只看该作者
Re: unix command 和 sas 一起使用的问题
[quote="死猪头":3ct3akwd]宏参数两点假设:
(1) dir是绝对路精,不含空隔或其它杂碎
(2) user存在
Also assuming standard Unix permission instead of ACL.
把结果捣到EXCEL有好多种办法,不用说了。
[code:3ct3akwd]
%macro zhutou(user=, dir=);
filename id pipe "groups &user";
data groups;
infile id;
length groups $ 255;
input;
groups = substr(_infile_, find(_infile_, ':')+2);
call symputx('groups', cats('"', tranwrd(trim(groups), ' ', '","'), '"'));
filename ls pipe "ls -lR --time-style=+%nrstr(%%Y-%%m-%%d) &dir";
data permission;
infile ls;
length permission $ 10 owner group $ 8 path $ 32767 parent $ 32767;
retain parent;
input;
if _infile_ =: '/' then do;
parent = substr(_infile_, 2, length(_infile_)-2);
end;
else if _infile_=:'d' then do;
permission = scan(_infile_,1,' ');
owner = scan(_infile_,3, ' ');
group = scan(_infile_,4, ' ');
call scan(_infile_,7,_n_,_error_, ' ');
_error_=0;
path = cats(parent, substr(_infile_, _n_));
if "&user" = owner then
&user = ifc(substr(permission,2,3) ne '---', 'Y', 'N');
else if group in (&groups) then
&user = ifc(substr(permission,5,3) ne '---', 'Y', 'N');
else
&user = ifc(substr(permission,8) ne '---', 'Y', 'N');
output;
end;
keep path &user;
proc print;
run;
filename id clear;
filename ls clear;
%mend;
%zhutou(user=hugo, dir=/home/test);
[/code:3ct3akwd][/quote:3ct3akwd]
老猪,你这个程序根据ls目录的访问权限来判断用户能不能访问是有问题的,我们可以用getfacl 来查看目录的详细访问控制,除了ls 出来的Permission外,还可能有些额外的设置,例如对某个特定的用户或者用户组赋予访问权限,那结果很可能是表面看他不能访问,但实际上是可以访问得到的
另外,请大伙帮我出出主意,帮帮我啦,好惨啊被上司催得 |
|