in my Python program. In another case I want to use the moreutils command ifne to check on the status of a pipe.sudo i2cset -y 1 0x6b 0x05 0x0f
moreutils is installed on my Pi v2 running Jessie.
For example, in the following code I would like to use ifne to display the status of the pipe before and after I read in the next record:
However, this code throws an error on either the
Code: Select all
#!/usr/bin/env python import subprocess #import moreutils nul_f = open('/dev/null', 'w') try: tcpflow = subprocess.Popen(['/usr/bin/sudo /usr/local/bin/tcpflow -C -0 -i eth1 -s -o /mnt/usbdrive/TCPFLOW/ tcp port 80'], stdout=subprocess.PIPE, shell=True, stderr=nul_f,) grep = subprocess.Popen(['stdbuf -oL egrep "GET"'], shell=True, stdin=tcpflow.stdout, stdout=subprocess.PIPE, stderr=nul_f) print 'Listener running' i=0 while i<10: i=i+1 # print 'ifne before = ' & moreutils.ifne(sh -c) line = grep.stdout.readline() # print 'ifne after = ' & moreutils.ifne(sh -c) print '\t --', i, line except KeyboardInterrupt: #end_of_pipe = tcpdmp.stdout print 'done' tcpflow.terminate() tcpflow.kill() grep.terminate() grep.kill() nul_f.close()
or theimport moreutils
I have tried to search for this but have not found anything which seems to help. Any help or "how to do it" references would be appreciated. Thanks....RDKprint ... & moreutils.ifne...