# page 71 subprocess # anything that is command prompt in o/s use subprocess import subprocess # the book uses Linux commands # windows commands # define the command we want to run as string #command = "dir c:\\python\\mypythonLevel2" command = "ping google.com" # create your shell to run the command thru result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) if result.returncode == 0: # Exit code 0 pass print("Command executed successfully") print("------- OUTPUT --------------") print(result.stdout) # terminal else: print("Command failed") print(result.stderr) # Exception Error