I am trying to redirect stdout to a file, Where print statements are being redirected but os.system o/p is not.
From This I have tried using ">" operator but not working for me.
I don't want to use subprocess or popen,
Below is the sample code.
Can any one help?
def ExecCMS_AGT_DB(cmd):
sys.stdout=open(cmd+'.txt','w')
print "\ncmd $: "+cmd+" start"
os.system(cmd+" start")
print "\ncmd $: "+cmd+" stop"
os.system(cmd+" stop")
sys.stdout.close()
def ExecCmd():
OldStdout=sys.stdout
ExecCMS_AGT_DB("srocms")
sys.stdout=OldStdout
#if __name__=="__main__":
ExecCmd()