I have a Python script which uses os.system() to call certain commands an Linux machine.
These commands might be standard commands such as ls, grep etc., or some custom commands present on that machine.
I want to trace what syscalls get called by these commands, but within the Python script itself. So, once I do:
os.system(command)
I want to return a list of all system calls made by that particular command.
So that I can iterate over the list and filter for any syscalls I need to investigate. Ideally, what I am planning to do is create a dictionary which will help me map the parameters that I gave to my command above, and what went in to the syscall eventually.
Is there a nice Pythonic way to do this?
os.system(...)to, say,self.system(...)? If so, write a wrapper that logs each call before making the actual call.os.system('strace ' + command)and parse the output but from @ColinSchoen's answer it looks like p-trace is a better way.