亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 3582 | 回復: 2
打印 上一主題 下一主題

[文本處理] 為啥報 readonly variable [復制鏈接]

論壇徽章:
0
跳轉到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2013-05-06 14:16 |只看該作者 |倒序瀏覽
寫了一個腳本,用于將一臺服務器上的USER信息復制到另一臺上的。(一個suse,一個rhel)

while read USER UID GID DIR SH PASSWD
do
useradd -m -d $DIR -u $UID -g $GID -s $SH $USER
echo -e "$PASSWD\n$PASSWD\n" |passwd $USER
done < ftp_userpassword.txt

more [root@lxbftp01 ~]# more ftp_userpassword.txt
user1 1001    100     /ftp/user1   /bin/bash       passwd1
user2   1002    100     /ftp/user2       /bin/bash       passwd2
user3   1003    100     /ftp/user3      /bin/bash       passwd3


結果卻是一直報錯
./add_ftpuser.sh
./add_ftpuser.sh: line 5: UID: readonly variable
useradd: UID 0 is not unique
passwd: Unknown user name 'user1'.
./add_ftpuser.sh: line 5: UID: readonly variable
useradd: UID 0 is not unique
passwd: Unknown user name 'user2'.
./add_ftpuser.sh: line 5: UID: readonly variable
useradd: UID 0 is not unique
passwd: Unknown user name 'user3'.

奇怪的是,UID和GID都是數字,但是一個報錯,一個正常,用bash -x 方式執(zhí)行,可以看到gid都被正常賦值
+ read USER UID GID DIR SH PASSWD
add_ftpuser.sh: line 5: UID: readonly variable
+ useradd -m -d /ftp/user1 -u 0 -g 100 -s /bin/bash user1
useradd: UID 0 is not unique

請高手指點

論壇徽章:
4
技術圖書徽章
日期:2013-09-23 10:22:37獅子座
日期:2013-10-15 23:31:54卯兔
日期:2013-11-11 17:33:15金牛座
日期:2013-11-15 17:25:28
2 [報告]
發(fā)表于 2013-05-06 14:22 |只看該作者
本帖最后由 nbrr 于 2013-05-06 14:27 編輯

看abs, bash internal variables
http://tldp.org/LDP/abs/html/internalvariables.html
This is the current user's real id, even if she has temporarily assumed another identity through su. $UID is a readonly variable, not subject to change from the command line or within a script,

你可以換個名字
while read ftpUSER ftpUID ftpGID ftpDIR ftpSH ftpPASSWD

論壇徽章:
0
3 [報告]
發(fā)表于 2013-05-06 14:38 |只看該作者
nbrr 發(fā)表于 2013-05-06 14:22
看abs, bash internal variables
http://tldp.org/LDP/abs/html/internalvariables.html
This is the cur ...


原來是和原有的變量重名了,多謝
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術有限公司. 版權所有 京ICP備16024965號-6 北京市公安局海淀分局網監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯網協會會員  聯系我們:huangweiwei@itpub.net
感謝所有關心和支持過ChinaUnix的朋友們 轉載本站內容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP