I am trying to write a program in Python3 that will use the file and run it in other programs. The difficulty lies in the fact that other programs have different options at startup and the output of the first used program is an input for the second.

I use subprocess, but I don’t quite understand how to make the first output used as the input of the second program, given that input and output are options that are set to run each program.

Maybe there are some other ways besides using subprocess for this task? Please advise on the best architecture options for the new program.

    1 answer 1

    No difficulty here

    list_dir = Popen(['ls', '-l'], stdout=PIPE) count_lines = Popen(['wc', '-l'], stdin=list_dir.stdout, stdout=PIPE)