#!/usr/bin/python import subprocess; import sys; if len(sys.argv) != 2: print("usage: {} file".format(sys.argv[0])) sys.exit(1) file = sys.argv[1] output = subprocess.check_output(['ldd',file]) for line in output.split("\n"): words = line.split() if len(words) > 3: print words[2]