1.假设b.txt里面有几万条类似的内容(实际上b.txt是由a.txt处理过来的,把a.txt中含有uid的项全部截取下来,其他的删除),
uid=tivoli,ou=Applications,o=hisense.com,o=isp
uid=zc,ou=Applications,o=hisense.com,o=isp
uid=docsdev,ou=Applications,o=hisense.com,o=isp
uid=gfjira,ou=Applications,o=hisense.com,o=isp
|
2.而最终我执行要的答案是类似下面的内容,最终用TAM命令导入到TAM账户中。
user import tivoli uid=tivoli,ou=Applications,o=hisense.com,o=isp
user import zc uid=zc,ou=Applications,o=hisense.com,o=isp
user import docsdev uid=docsdev,ou=Applications,o=hisense.com,o=isp
user import gfjira uid=gfjira,ou=Applications,o=hisense.com,o=isp
|
3.明确需求后编写脚本
-
#/bin/sh
-
/opt/ibm/ldap/V6.3/bin/ldapsearch -D cn=root -w wwwwww -b o=isp objectClass=* dn >> /home/a.txt
-
cat /home/a.txt | sed -n '/uid=/'p | while read line
-
do
-
echo $line >> b.txt
-
done
-
cat /home/a.txt | sed -n '/uid=/'p | sed 's/\,/ /g' | sed 's/\=/ /g' | awk '{print $2}' | while read line1
-
do
-
echo "echo user import" $line1 >> c.txt
-
done
-
paste c.txt b.txt >> d.txt
-
pdadmin -a sec_master -p password ./d.txt
-
rm -rf a.txt b.txt c.txt d.txt
阅读(1313) | 评论(0) | 转发(0) |