我收到以下錯誤語法錯誤:擊:靠近意外的標記'其他」
./adduser.sh: line 21: syntax error near unexpected token `else'
./adduser.sh: line 21: ` else'
我已經困在這裏了一個小時,我只是不明白。
#!/bin/bash
#==========================================================================================================================================
# Script Name: adduser.sh
# By: Tim mayo
# Date: 3/2013
# Purpose: Add a user to the Linux system
# Command line: adduser.sh
#
#==========================================================================================================================================
read -p "Enter username : " username
read -s -p "Enter password : " password
egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "$username exists!"
exit 1
else
pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
useradd -m -p $pass $username
[ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
fi
else
echo "Root user can only add a user to the Linux system"
exit 2
fi
你可以把整個腳本請在identation表明有缺失的部分。 – 2013-03-16 19:10:48