0

I am able to open cmd.exe using script

import subprocess
subprocess.call("C:\Windows\System32\cmd.exe",shell=True)

But I am unable to send input command to cmd.exe open. I want to achieve something like below mentioned using script

1) script give input command like python to cmd.exe open enter image description here

2) After that script give input command like print "hello" to python prompt comes enter image description here

RaulGupta
  • 351
  • 1
  • 3
  • 9

2 Answers2

0

Why not use Python to create a batch file that prints what you want, then execute that batch file? You could either return immediately or keep the command interpreter open: it depends on the command switches you use to run the batch file.

Rory Daulton
  • 21,934
  • 6
  • 42
  • 50
  • I know that can be done, but what I want to know is how to give input to any xyz.exe open through python script. – RaulGupta Jul 16 '16 at 19:56
0

You could create a file hello.py containing print "hello", and run it through cmd ?

from subprocess import call
call(["python", "hello.py"])
Albyorix
  • 637
  • 1
  • 6
  • 13