pawk icon indicating copy to clipboard operation
pawk copied to clipboard

Invoke pawk from a python script?

Open stephenfrench9 opened this issue 3 years ago • 1 comments

Is it possible to invoke pawk from a python script, without using subprocess.run?

I am imagining something like:

import pawk

my_pawk_program = ' .... '

results = pawk.run(my_pawk_program)

stephenfrench9 avatar Jul 17 '22 16:07 stephenfrench9

You could probably replicate the invocation here https://github.com/alecthomas/pawk/blob/e4e8716973800ea215d7cec976374c1c770046e6/pawk.py#L244-L253

Something like:

# error handling skipped
pawk.run(["pawk", "/etc/"], io.StringIO("/tmp\n/dev\n/etc/passwd\n"), sys.stdout)

Or maybe you can figure out how to call this method directly https://github.com/alecthomas/pawk/blob/e4e8716973800ea215d7cec976374c1c770046e6/pawk.py#L163

dwurf avatar Jul 18 '22 04:07 dwurf