I am writing some bash scripts that I want to deliver and mantain with a deb package. As I need to list the dependencies of the package, I would like to find all executables that the scripts are calling and find which packages do they belong.
Is it possible to list all executables called by a bash script?
EDIT
To better clarify: say that my script is
#!/bin/sh
echo "hello"
cat file.txt | grep -v "STRING"
if [ -d $SOMEDIR ]; then
./something.sh
else
./something_else.sh
fi
I would like to analyze the content of such script and the output should be:
echo
cat
grep
./something.sh
./something_else.sh
(regardless of any other possible executable called by the other two *.sh scripts)
You can run your scripts through strace and check the executables invoked
$ strace -qqfe execve ./script.sh
and you'll get something like
execve("./script.sh", ["./script.sh"], [/* 81 vars */]) = 0
[pid 27651] execve("/bin/grep", ["grep", "hello"], [/* 80 vars */]) = 0
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With