python执行shell命令批量修改coremail系统用户信息
时间:2007-05-11 来源:cnscn2008
.知识
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" "[email protected]"
"19" "123456" "tom1" "[email protected]"
"20" "123456789" "tom2" "[email protected]"
"18" "123410" "tom3" "[email protected]"
"13" "123456" "tom4" "[email protected]"
"11" "123456" "tom5" "[email protected]"
"17" "123456" "tom6" "[email protected]"
"15" "pstoto" "tom7" "[email protected]"
.[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
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" "[email protected]"
"19" "123456" "tom1" "[email protected]"
"20" "123456789" "tom2" "[email protected]"
"18" "123410" "tom3" "[email protected]"
"13" "123456" "tom4" "[email protected]"
"11" "123456" "tom5" "[email protected]"
"17" "123456" "tom6" "[email protected]"
"15" "pstoto" "tom7" "[email protected]"
.[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
相关阅读 更多 +