1

lets assume that I have the following python script :

python_script.py

import os 
import subprocess 

subprocess.Popen(['python2',os.path.join(os.path.expanduser("~"),"test","top_block.py")])

I have to check if this subprocess is calling a particular shared library (lib_modified.so). If it's true go ahead with the execution otherwise stop it.

Is there a way to achieve this?

  • `if "lib_modified.so" in open(the_filename).read(): execute_script(); else: dont_execute_script()`? – Kevin Jun 15 '16 at 15:29
  • What do you mean? Inside the python_script.py there are no references to lib_modified.so. It uses some APIs provided by this lib. Just this. – Felice Di Stolfa Jun 15 '16 at 15:35
  • I mean you should check `top_block.py` for the string "lib_modified.so", not `python_script.py`. – Kevin Jun 15 '16 at 15:38
  • ah sorry. I was wrong. Inside top_block.py there are no reference to lib_modied.so. – Felice Di Stolfa Jun 15 '16 at 15:39
  • Then how do you know that top_block.py is calling lib_modified.so? Sorry, I'm not terribly familiar with shared libraries. – Kevin Jun 15 '16 at 15:40
  • Ah no problem me too :). I know it because it's a script to run a flowgraph into GNURadio using UHD , so it calls for sure libuhd.so. – Felice Di Stolfa Jun 15 '16 at 15:42
  • 1
    do you want to check for debugging purpose or do you want an automate way to check it ? in the first case it looks like a duplicate of http://stackoverflow.com/q/5103443/128629 – Xavier Combelle Jun 15 '16 at 16:53
  • I would like find an automate way to check it, or a way to build a function to do it. Btw now i will check the discussion that you suggested. Thanks – Felice Di Stolfa Jun 15 '16 at 17:18

0 Answers0