user775093
user775093

Reputation: 749

Tracing Linux commands using Python

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?

Upvotes: 0

Views: 652

Answers (1)

Colin Schoen
Colin Schoen

Reputation: 2592

Have a look at python p-trace

http://python-ptrace.readthedocs.org/en/latest/syscall.html

Upvotes: 1

Related Questions