简体   繁体   中英

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM