Skip to main content

Posts

Showing posts with the label string

[Linux/vi] multi search string

[1stString] : First string to find. [2ndString] : Second string to find Or Search ( Use "\|" ) /[1stString]\|[2ndString] And Search (Use ".*" ) /[1stString].*[2ndString]/ Reference: http://www.linuxquestions.org/questions/linux-software-2/searching-multiple-patterns-through-vi-editor-725155/

[python] get string from output of other process

1.  The Script ---------------------------------- #!/usr/bin/python import subprocess def getCallResult(cmdARGS):   fd_popen = subprocess.Popen(cmdARGS.split(), stdout=subprocess.PIPE).stdout   data = fd_popen.read().strip()   fd_popen.close()   return data data = getCallResult("ls -la") print (data) ---------------------------------- 2. Result Example ---------------------------------- # python test.py total 524 drwxrwxr-x  4 parkmo parkmo   4096  1월 27 16:30 . drwxrwxr-x 45 parkmo parkmo   4096  1월 27 11:59 .. drw-rw-r--  1 parkmo parkmo    421  1월 27 12:01 test.py .. .. 1) If you don't want use split() when call subprocess.Popen, use [ ]. subprocess.Popen(["ls", "-la"], stdout=subprocess.PIPE).stdout 2) If you can want to file descriptor.   fd_popen = subprocess.Popen(cmdARGS.split(), stdout=subprocess.PIPE).wait() You can use Blocking or Non-Blocking. Test Environment: Pytho