Aug-17-2018, 03:48 PM
Hi,
Am using subprocess.call() method to send some arguments to executable (myproject.exe).Its working fine am able to pass the arguments and perform the required operation but i want to write the output as text file which is not happening using below code in windows.i have tried some approaches but still not working.
Approach - 1: (Text file is creating but output is not writing)
Am using subprocess.call() method to send some arguments to executable (myproject.exe).Its working fine am able to pass the arguments and perform the required operation but i want to write the output as text file which is not happening using below code in windows.i have tried some approaches but still not working.
Approach - 1: (Text file is creating but output is not writing)
process = subprocess.call(r"C:\Users\ohm_seenivasan\test\myproject.exe /getUserDetails") print(process) f = open(r"C:\Users\ohm_seenivasan\Desktop\ConsoleReport.txt",'w') f.write(process) f.close()Approach - 2: (Text file is creating but output is not writing)
#file_object = open(r"C:\Users\ohm_seenivasan\Desktop\ConsoleReport.txt", "w") #subprocess.call(r"C:\Users\ohm_seenivasan\test\myproject.exe /getUserDetails", stdout=file_object) #file_object.close() #print(file_object.read())