Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python3/10_Modules/06_subprocess/00_subprocess_ex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions python3/10_Modules/06_subprocess/01_subprocess_ex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions python3/10_Modules/06_subprocess/02_subprocess_ex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion python3/10_Modules/06_subprocess/cleanup_pid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading