我已经得到了OSX下面的shell脚本我想用它来纠正一个用户目录/修复权限,但我得到的错误:傻shell脚本错误
bash-3.2# sh fix-perms.sh
fix-perms.sh: line 23: syntax error near unexpected token `else'
fix-perms.sh: line 23: `else'
我的脚本:
#!/bin/sh
# Script fixes permissions in Users directory
# Set PATH as shortcut
#
PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH
# First verify volume is mounted before executing
if [ -d /Volumes/UserStorage ] ;
then
USERS=`mktemp -t users-XXXXX.log`
ls -1 /Volumes/UserStorage/Users > $USERS
for i in `cat $USERS`; do
chmod -R 700 /Volumes/UserStorage/Users/$i
find /Volumes/UserStorage/Users/$i -type d -exec chmod 701 {} \;
exit 0
else
echo Volume Not Mounted
exit 1
fi
这是愚蠢的/愚蠢的,我失踪了,但如果我能看到它,我就会变得更糟!
感谢您的提示/洞察力提前。
Dan
啊是的,这是问题所在。但是如果完成循环而不打破它,我怎样才能保持退出状态? – Dan
@Doug:我不确定你的意思。 'exit 0'将终止整个脚本。我猜你想把'exit 0'_____ after _ done' ... – 2013-01-19 04:49:59
弗拉德,是的,回声需要遵循'完成'。现在都好。谢谢你的帮助! – Dan