diff --git a/python3/10_Modules/06_subprocess/00_subprocess_ex.py b/python3/10_Modules/06_subprocess/00_subprocess_ex.py index e18be429..11ade470 100644 --- a/python3/10_Modules/06_subprocess/00_subprocess_ex.py +++ b/python3/10_Modules/06_subprocess/00_subprocess_ex.py @@ -14,7 +14,7 @@ def execute_command(cmd): def get_execution_result(cmd): p = subprocess.Popen( - cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE + cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) output, err = p.communicate() diff --git a/python3/10_Modules/06_subprocess/01_subprocess_ex.py b/python3/10_Modules/06_subprocess/01_subprocess_ex.py index 8051525c..d6d84b3d 100644 --- a/python3/10_Modules/06_subprocess/01_subprocess_ex.py +++ b/python3/10_Modules/06_subprocess/01_subprocess_ex.py @@ -10,8 +10,8 @@ if sys.platform in ("linux", "linux2", "darwin"): cmd = "ifconfig" os.system(cmd) - subprocess.call(cmd, shell=True) - myprocess = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE) + subprocess.call(cmd, shell=False) + myprocess = subprocess.Popen(cmd, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE) output, err = myprocess.communicate() print("output==============\n", output) print("err=================\n", err) diff --git a/python3/10_Modules/06_subprocess/02_subprocess_ex.py b/python3/10_Modules/06_subprocess/02_subprocess_ex.py index ebafd2af..c0dd49f4 100644 --- a/python3/10_Modules/06_subprocess/02_subprocess_ex.py +++ b/python3/10_Modules/06_subprocess/02_subprocess_ex.py @@ -2,9 +2,9 @@ import sys if sys.platform == "win32": - subprocess.call(["dir", "/x"], shell=True) + subprocess.call(["dir", "/x"], shell=False) else: - subprocess.call(["ls", "-1"], shell=True) + subprocess.call(["ls", "-1"], shell=False) # Command with shell expansion if sys.platform == "win32": diff --git a/python3/10_Modules/06_subprocess/cleanup_pid.py b/python3/10_Modules/06_subprocess/cleanup_pid.py index bee2b800..5370942d 100644 --- a/python3/10_Modules/06_subprocess/cleanup_pid.py +++ b/python3/10_Modules/06_subprocess/cleanup_pid.py @@ -21,7 +21,7 @@ def check_pid(pid): def get_elapsed_time(pid): """get the elapsed time of the process with this pid""" cmd = f"ps -p {str(pid)} -o pid,etime" - proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) + proc = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE) # get data from stdout proc.wait() results = proc.stdout.readlines() diff --git a/python3/11_File_Operations/05_pdf_files/a_create_pdfs/c_report_generation_in_required_format.py b/python3/11_File_Operations/05_pdf_files/a_create_pdfs/c_report_generation_in_required_format.py index fe2ab6a6..32b8d30d 100644 --- a/python3/11_File_Operations/05_pdf_files/a_create_pdfs/c_report_generation_in_required_format.py +++ b/python3/11_File_Operations/05_pdf_files/a_create_pdfs/c_report_generation_in_required_format.py @@ -109,8 +109,7 @@ def __init__(self): process = subprocess.Popen( [path_to_pdf], bufsize=2048, - shell=True, - stdin=subprocess.PIPE, + shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, ) process.wait()