Skip to content
Discussion options

You must be logged in to vote

From the docs for subprocess.call:

Run the command described by args. Wait for command to complete, then return the returncode attribute.

Here's a quick demo which might help explain this:

import subprocess

pattern = input("Insert string: ")
command = f"ls | grep {pattern}"

print("##### START OF SUBPROCESS COMMAND #####")
output = subprocess.call(command, shell=True)
print("##### END OF SUBPROCESS COMMAND #####\n")

print(f"Output value: {output}")
print(f"Type of output: {type(output)}")

You want to check the output from the executed command - perhaps there's a another subprocess function that would help here...?

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@totordev
Comment options

@TomJGooding
Comment options

Answer selected by davep
@totordev
Comment options

@davep
Comment options

@totordev
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2387 on April 26, 2023 15:44.