-1

I want to open a cmd and then input data into the command line from python. I plan to call PEST calibration software to open from within python and I want to start by opening a cmd.

I am using Python 2.7 and so subprocess doesn't seem to work. I have tried os.system('cmd') and I can open the prompt but I can't input any data.

import os
os.system('cmd')
Emma
  • 443
  • 2
  • 5
  • 13
  • what was your subprocess code? – Jeril Feb 11 '19 at 08:05
  • I tried the following: subprocess.call("cmd" + "pest", shell=True) subprocess.Popen('cmd') subprocess.run('cmd') – Emma Feb 11 '19 at 08:07
  • What is the command to run PEST calibration software, and what happens when you run the PEST command – Jeril Feb 11 '19 at 08:09
  • To run PEST from the cmd, I type: pest forward.pst , where pest is the name of the application and forward.pst is a text file that pest needs to open and read to run. – Emma Feb 11 '19 at 08:22
  • Used to work for me on Linux, as far as I can remember, but since you're on Windows, I believe what you are looking for has been answered in this [other question](https://stackoverflow.com/questions/14894993/running-windows-shell-commands-with-python). – Jaume Sabater Feb 11 '19 at 08:09

1 Answers1

0

You should be able to pass the exact resulting string to os.system(). Ex:

os.system('notepad.exe')

In other words, os.system behaves the same way a console would.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
S. L.
  • 630
  • 8
  • 19
  • I tried inputting the call I use to launch PEST in the cmd into os.system() os.system('pest forward.pst') But a prompt didn't open. It looked like a prompt may have opened but then closed so quickly I couldn't even see it. – Emma Feb 11 '19 at 08:33