我需要写一个OS X登录钩子脚本,知道用户的当前主文件夹中。由于用户是Active Directory用户,他们的主文件夹不存储在/用户,所以我不能简单地硬code的完整路径。
I need to write a OS X login hook script that is aware of the users current home folder. Since the users are Active Directory users, their home folders are not stored in /Users so I can't simply hard code the full path.
由于登录连接是由后台程序以root身份运行,我不能用$ HOME,〜等无论是。
Since the login hook is run by a daemon as root, I can not use $HOME, ~, etc either.
唯一的一块信息我是被传入作为参数传递给该脚本的用户名。
The only piece of info I have is the users name which is passed in as an argument to the script.
有没有什么办法可以解决考虑到所有这些限制了用户的主文件夹?该脚本并不需要是一个登录钩必然,但它确实需要运行该登录到本机的所有AD用户。
Is there any way to resolve the users home folder given all these restraints? The script does not need to be a login hook necessarily, but it does need to run for all AD users that log into the machine.
推荐答案事实证明,这个命令的伟大工程:
It turns out this command works great:
finger $USER_NAME | grep Directory | expand | cut -d ' ' -f 2
是必要的,因为如果扩展的文件夹路径很长,手指会用一个选项卡分离的空间领域,而不是。
The expand is needed because if the folder path is long, finger will use a tab to separate the fields instead of a space.
更多推荐
查找在OS X登录钩子的Active Directory用户主文件夹
发布评论