Reputation: 937
I have simple python code took from here only.It is
import os
os.system("start /WAIT cmd /c {ping google.com -t }")
My intention is ,I have to open a command prompt and then have to ping Google. Program should stopped when I close command prompt.
But , while I am doing with above code command prompt appearing but auto-closing.
I am not understanding what I have to do because I am pretty new.
I am using Python 2.7.6 in Windows 7 64-Bit.
Thank you.
Upvotes: 2
Views: 68
Reputation: 369424
According to cmd /?
, there's no mention about braces.
C:\>cmd /?
Starts a new instance of the Windows command interpreter
CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
[[/S] [/C | /K] string]
/C Carries out the command specified by string and then terminates
/K Carries out the command specified by string but remains
....
Remove braces that surround the ping command. Then it will works as you expected.
import os
os.system("start /WAIT cmd /c ping google.com -t")
Upvotes: 1