Skip to content
Snippets Groups Projects
Commit f63ac8af authored by Florian Fischer's avatar Florian Fischer
Browse files

add function to prefix cmd with abspath using whereis

parent 53d42fdc
No related branches found
No related tags found
No related merge requests found
import os import os
import subprocess
import sys import sys
import src.globalvars import src.globalvars
...@@ -23,6 +24,23 @@ def find_cmd(cmd): ...@@ -23,6 +24,23 @@ def find_cmd(cmd):
return None return None
def prefix_cmd_with_abspath(cmd):
"""Prefix cmd with the abspath of the first word
Usefull if cmd should be executed by the loader of a custom glibc."""
binary_end = cmd.find(" ")
binary_end = None if binary_end == -1 else binary_end
cmd_start = len(cmd) if binary_end == None else binary_end
binary_abspath = subprocess.run(["whereis", cmd[0:binary_end]],
stdout=subprocess.PIPE,
universal_newlines=True).stdout.split()[1]
return binary_abspath + " " + cmd[binary_end:]
def allocbench_msg(color, *objects, sep=' ', end='\n', file=sys.stdout): def allocbench_msg(color, *objects, sep=' ', end='\n', file=sys.stdout):
if src.globalvars.verbosity < 0: if src.globalvars.verbosity < 0:
return return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment