Python Subprocess 모듈 사용법

Email IconExcel IconBedrock Icon

2025-03-17(월) 금일 구현결과 call 함수는 deprecated 되어 아래와 같이 run으로 구현하고, returncode를 받아서 처리하는 것을 선호.

def chmod_directory(directory_path): # Alternative method using os.chmod

# Method 1: Using subprocess with sudo chmod command (recommended for Linux/Unix)
result = subprocess.run([‘sudo’,‘chmod’, ‘-R’, ‘766’, directory_path])
return result.returncode

 



//25.03.16 파이썬 DB wp_db_sync.py에서 어떤함수를 쓰는게 좋을지 상세분석

result_code = subprocess.call()

Result_code 0은 True이고, 0이 아니면 False임.

https://webnautes.tistory.com/2283

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

0
Would love your thoughts, please comment.x
()
x