Inside a bash shell script, I am attempting to
- Find an executable in an unknown position the current directory (guaranteed to exist)
- Run that executable, passing in a set of files as arguments.
Given that:
- The executable may be in a different sub-directory on a given system (No control over that)
- The executable will not be in
$PATH
Currently, I can find the executable using:
#!/bin/bash
EXECUTABLE=$(find . -name 'executable_name*' -type f)
(suffix wildcard for platform-related reasons)
Trying to then execute it fails, returning:
No such file or directory ./path/to/executable_name
*Note: The executable does work if I supply the exact path returned by find
explicitly
Trying the following two options all fail with the same error:
$EXECUTABLE {...}
eval "$EXECUTABLE {...}"
Related Question
As far as I understand using -exec {}
with find
will pass the find
results as args to the executable, which is the opposite of what I'm trying to achieve.
Setting execution permissions beforehand on the target file also yields the same results