I am using Python to capture the output of Linux more. However, the file contains the characters:
<--- More --->^M ^M
How do I use Python to clean the lines? Or use more once more time to cleanit up?
I am using Python to capture the output of Linux more. However, the file contains the characters:
<--- More --->^M ^M
How do I use Python to clean the lines? Or use more once more time to cleanit up?
This isn't guaranteed to work, but you should try setting PAGER
to cat
in the environment of the child process. You can't do that with subprocess.call
but you can do it with subprocess.Popen
:
childenv = os.environ.copy()
childenv['PAGER'] = 'cat'
proc = subprocess.Popen(executable="yourprogram",
args=["yourprogram", ...],
env=childenv,
stdout=subprocess.PIPE,
...)
# proc.stdout *may* now be free of `more` detritus