The first if
statement doesn't work if there is no output from the command. I also tried to evaluate the exit status but this also doesn't work?
unhide-tcp
output:
# unhide-tcp
Unhide-tcp 20130526
Copyright © 2013 Yago Jesus & Patrick Gouin
License GPLv3+ : GNU GPL version 3 or later
http://www.unhide-forensics.info
Used options:
[*]Starting TCP checking
Found Hidden port that not appears in ss: 1025
Found Hidden port that not appears in ss: 1026
[*]Starting UDP checking
Script:
#!/usr/bin/env bash
unhide-tcp | grep "^Found" | while IFS=":" read -a PORT; do
if [ -z ${PORT[1]} ]; then
echo "No hidden ports found."
elif [ -n ${PORT[1]} ]; then
echo ${PORT[@]}
fi
done