Python Forum

Full Version: Run CMD Command In Python Script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a couple of batch command and also wanted to execute sql query commands like sqlcmd using Python script.

sqlcmd -S catalyst.database.windows.net -d Catalyst -U Automation -P F537!q -Q "Exec esusp_MRA_Report_SL4_HDR"
bcp MDR.MDReportHeader out "D:\Client Data\Catalyst\MRT\SL4_HDR.txt" -S catalystmetals.database.windows.net -d CatalystQuest -U Automation -P F537!qAv+u_Ky -q -c -t \t

sqlcmd -S catalyst.database.windows.net -d Catalyst -U Automation -P F537!q -Q "Exec esusp_MRA_Report_SL4"
bcp mdr.MDReport out "D:\Client Data\Catalyst\MRT\SL4_DATA.txt" -S catalystmetals.database.windows.net -d CatalystQuest -U Automation -P F537!qAv+u_Ky -q -c -t \t

Copy "D:\Client Data\Catalyst\MRT\SL4_HDR.txt" + "D:\Client Data\Catalyst\MRT\SL4_DATA.txt" "D:\Client Data\Catalyst\MRT\SL4.txt"

Del "D:\Client Data\Catalyst\MRT\SL4_HDR.txt"
Del "D:\Client Data\Catalyst\MRT\SL4_DATA.txt"
Can anyone tell me how to run all the commands from python script?
Subprocess' page at Python module of the week