I see a lot of questions about passing python outputs to bash script variables, but is there a way to do this the other way around? I have a bash script that takes a user as an argument and depending on it's one type of user there is an output. If it's a different type of user, the output is empty. I would like in a python script to iterate over a list of users and pass them as arguments to the bash script. Then, if the output is not open, to store those users in a list.
import subprocess
non_empty = []
for user in users:
output = subprocess.run(["path/to/bash_script",
user], shell=True)
if len(output) > 0:
non_empty.append(user)
I thought that subprocess might do the trick, but the output is the same regardless of if the results from the bash script were empty or not.
Thanks