免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1856 | 回复: 0
打印 上一主题 下一主题

python执行shell命令批量修改coremail系统用户信息 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-05-11 16:26 |只看该作者 |倒序浏览

                .知识
objFile=open("filename", 'rw')
line=objFile. readline()
objFile.close()
urllib.urlencode({'a':1, 'b':2,'c':3})
os.system("cmd")
str.split(separator_char)
len(line)
str.strip(char)
.mail_list.txt
"11" "123456" "tom" "abc@xx.com"
"19" "123456" "tom1" "abcd@xx.com"
"20" "123456789" "tom2" "abcde@xx.com"
"18" "123410" "tom3" "abcdef@xx.com"
"13" "123456" "tom4" "abcdefg@xx.com"
"11" "123456" "tom5" "abcdefgh@xx.com"
"17" "123456" "tom6" "abcdefghi@xx.com"
"15" "pstoto" "tom7" "abcdefghij@xx.com"
.[root@localhost script]# cat alteruser_bat.py
#!/usr/bin/python
import urllib;import os;
try:
   f=open("mail_list.txt", "r");
   while  True:
     line=f.readline();
     if len(line) == 0:
       break;
     arr=line.strip().split(' ');
     cmd="./alteruser 172.16.0.223 6195 "+arr[3].strip('"')+" \""+urllib.urlencode({'password': arr[1].strip('"'), 'org_unit_id': arr[0].strip('"'),'True_name': arr[2].strip('"') })+"\"";
     print cmd
     os.system(cmd);
finally:
   f.close()
#end of script
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/13329/showart_298698.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP