Python Forum
Run CMD Command In Python Script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run CMD Command In Python Script
#1
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?
Reply
#2
subprocess
Gribouillis likes this post
Reply
#3
Subprocess' page at Python module of the week
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is possible to run the python command to call python script on linux? cuten222 6 720 Jan-30-2024, 09:05 PM
Last Post: DeaD_EyE
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,185 Jun-29-2023, 11:57 AM
Last Post: gologica
  How to kill a bash script running as root from a python script? jc_lafleur 4 5,875 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 2,290 May-28-2020, 05:27 PM
Last Post: micseydel
  Script works when executed from command prompt but not when executed in SDP Tippex 0 2,000 Apr-07-2020, 04:26 PM
Last Post: Tippex
  Package python script which has different libraries as a single executable or script tej7gandhi 1 2,618 May-11-2019, 08:12 PM
Last Post: keames
  Script won't continue after command line skip671 7 4,853 Oct-15-2018, 07:37 PM
Last Post: snippsat
  Pyinstaller to execute a script in command prompt Ciroxxx 0 2,083 Sep-18-2018, 10:17 AM
Last Post: Ciroxxx
  How to run python script which has dependent python script in another folder? PrateekG 1 3,148 May-23-2018, 04:50 PM
Last Post: snippsat
  How to call one python script and use its output in another python script lravikumarvsp 3 32,385 May-16-2018, 02:08 AM
Last Post: lravikumarvsp

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020