Skip to content

Commit e0ec26c

Browse files
authored
Merge pull request #43 from bcoles/patch-2
Check required commands exist in $PATH - Fix #31
2 parents b090da8 + cc82c8b commit e0ec26c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

mimipenguin.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,25 @@ fi
1414
#Store results to cleanup later
1515
export RESULTS=""
1616

17+
# check if a command exists in $PATH
18+
command_exists () {
19+
20+
command -v "${1}" >/dev/null 2>&1
21+
}
22+
23+
# check for required executables in $PATH
24+
if ! command_exists strings; then
25+
echo "Error: command 'strings' not found in ${PATH}"
26+
exit 1
27+
fi
28+
if ! command_exists grep; then
29+
echo "Error: command 'grep' not found in ${PATH}"
30+
exit 1
31+
fi
32+
if ! command_exists python2; then
33+
echo "Error: command 'python2' not found in ${PATH}"
34+
exit 1
35+
fi
1736

1837
# $1 = PID, $2 = output_file, $3 = operating system
1938
function dump_pid () {

0 commit comments

Comments
 (0)