ngrep

How to spawn another process and capture output in python?

徘徊边缘 提交于 2019-12-10 16:14:51
问题 I'm just learning Python but have about 16 years experience with PERL and PHP. I'm trying to get the output of ngrep and write it to a log file using Python while also tailing the log file. I've seen some examples online but some seem old and outdated and others use shell=True which is discouraged. In perl I just use something similar to the following #!/usr/bin/perl open(NGFH,"ngrep -iW byline $filter"); while ($line = <NGFH>) { open(LOG,">> /path/to/file.log") // highlighting, filtering,