2013년 12월 17일 화요일

[Python] Where file search utility

This utility searches all the paths in a semi-colon delimited environment variable list for files matching a given filespec. By default, PATH is used for the enviroment. For example, on my computer

C:\>where note*.exe
C:\WINNT\system32\notepad.exe
C:\WINNT\NOTEPAD.EXE


소스코드:

"""Searches a path for a specified file.
"""

__author__ = "Bill McNeill <billmcn@speakeasy.net>"
__version__ = "1.0"

import sys
import os
import os.path
import glob

def help():
        print """\
where (Environment) Filespec

Searches the paths specified in Environment for all files matching Filespec.
If Environment is not specified, the system PATH is used.\
"""

if len(sys.argv) == 3:
        paths = os.environ[sys.argv[1]]
        file = sys.argv[2]
elif len(sys.argv) == 2:
        paths = os.environ["PATH"]
        file = sys.argv[1]
else:
        help()
        sys.exit(0)

for path in paths.split(";"):
        for match in glob.glob(os.path.join(path, file)):
                print match

마이크로소프트 Outlook의 권한 상승 취약점(CVE-2023-23397) 제로데이 취약점

  면책 조항  이 블로그에는 민감한 정보가 포함되어 있습니다. 그러나 이 정보는 일부 공개적으로 알려져 있기 때문에 모든 정보를 삭제하지 않기로 결정했습니다. 공격의 간단성과 사용자 상호작용이 필요하지 않는 사실 때문에 모든 사용자가 즉시 시스템을 ...