2

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.

1 Answer 1

1

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")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.