意外令牌附近的语法错误`do'

时间:2016-08-27 14:24:22

标签: bash

需要帮助来创建它。

我的要求是需要从用户那里获取输入并在远程机器中创建用户。

echo -n "Enter username: "
read UserName
echo -n "Enter Comment "
read Gecos
echo -n "Enter group: "
read Group
echo -n "Enter shell: "
read Shell
do
ssh -qt ftdcsldapp660.ftiz.cummins.com sudo /usr/sbin/useradd -u $Uid -g $Group -c "$Gecos" -d /usr/users/$UserName -m  -s $Shell $UserName
done


[opsunix@ftdcsldapp660 tmp]$ ./test.sh
Enter username: test
Enter Comment test
Enter group: teset
Enter shell: /bin/ksh
./test.sh: line 9: syntax error near unexpected token `do'
./test.sh: line 9: `do'
[opsunix@ftdcsldapp660 tmp]$ 

但我收到此错误

1 个答案:

答案 0 :(得分:-1)

看起来像是一个剪切n贴错误 - 有一个剩余的"做"和"完成"可能来自前"而#34;

这是脚本的固定版本

echo -n "Enter username: "
read UserName
echo -n "Enter Comment "
read Gecos
echo -n "Enter group: "
read Group
echo -n "Enter shell: "
read Shell
#do
ssh -qt ftdcsldapp660.ftiz.cummins.com sudo /usr/sbin/useradd -u $Uid -g $Group -c "$Gecos" -d /usr/users/$UserName -m -s $Shell $UserName
#done