开发者

raw_input in python variable to cmd

How can I take this code, and take the raw_input and add "ping" before it in cmd, so it'll look like this in command prompt: [ping (raw_input)]

HERE开发者_JS百科 IS THE CODE:

          RS_usr = raw_input('input user here: ')
          from subprocess import Popen, PIPE, STDOUT


          p = Popen(['cmd.exe'], stdout=PIPE, stdin=PIPE, stderr=STDOUT)

          out,err = p.communicate(input=RS_usr)
          print(out)


If I understood you correctly you should change a couple of lines in your script:

p = Popen(['cmd.exe', '/k', 'set PROMPT=[Hello, (' + RS_usr + ')]' ], stdout=PIPE, stdin=PIPE, stderr=STDOUT)

out,err = p.communicate()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜