Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

2020-02-19から1日間の記事一覧

subprocessライブラリでパイプ処理をする

前回の続き。 シェルの醍醐味(?)といえばパイプ処理。 実際のところ output=`dmesg | grep hda`に相当するコマンドが、以下の様に。 p1 = Popen(["dmesg"], stdout=PIPE) p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE) #入力はp1のstdout p…