Be myself :: 특정 커멘드 결과값 계속 받아오기

달력

32024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

import subprocess
import shlex

def run_command(cmd):
    p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
    while True:
        output = process.stdout.readline()
        if output == '' and process.poll() is not None:
            break

        if output:
            print output
    rc = process.poll()
    return rc

def main():
    print "Catch go"
    cmd = "something"
    run_command(shlex.split(cmd))

if __name__ == '__main__':
    main()

Posted by flack3r
|