利用cmd实现组网产品任务

#coding=utf-8
import os,logging,ctypes,pdb
import subprocess
import time
from datetime import datetime
from datetime import timedelta
aMinute=timedelta(minutes=-5)
Now = datetime.now()
a = Now + aMinute
b=a +aMinute
# print 'Now=', Now.strftime('%Y%m%d%H%M')
# print 'a=',a.strftime('%Y%m%d%H%M')
# print 'b=',b.strftime('%Y%m%d%H%M')
# cmd = r"RadaS.exe -o=E: adar_operation est_bedoutputS3 -i="+radarfile+" /uc"
# try:
#     os.chdir(r"E: adar_operationexeLongJiang")
#     p = subprocess.Popen(cmd,shell=True)#,stdout=subprocess.PIPE)
# except:
#     print 'error->run command ',cmd ,' failed!'

cmd0 = r"RadaM.exe -o=E: adarexeoutputN3 -i=E: adarexeoutputS3 -t=%s  /uc"%Now.strftime('%Y%m%d%H%M')
cmd1 = r"RadaM.exe -o=E: adarexeoutputN3 -i=E: adarexeoutputS3 -t=%s  /uc"%a.strftime('%Y%m%d%H%M')
cmd2 = r"RadaM.exe -o=E: adarexeoutputN3 -i=E: adarexeoutputS3 -t=%s  /uc"%b.strftime('%Y%m%d%H%M')
print 'cmd0=', cmd0
print 'cmd1=', cmd1
print 'cmd2=', cmd2
try:
    os.chdir(r"E: adarexe")
    p0 = subprocess.Popen(cmd0,shell=True)#,stdout=subprocess.PIPE)
    p1 = subprocess.Popen(cmd1,shell=True)
    p2= subprocess.Popen(cmd2,shell=True)
except:
    print 'error->run command ',cmd ,' failed!'

原文地址:https://www.cnblogs.com/xiaoxiaoshuaishuai0219/p/6400308.html