5
# Pretty that we're the shell and that this command could not be
7
if [ "$FAKE_NMAP_NOT_FOUND" = "yes" ] ; then
8
echo "sh: ${prog}: command not found" >&2
15
Usage: $prog -n -oG - -PS 127.0.0.1 -p <port>[,<port> ...]
17
A fake nmap stub that prints items depending on the variable
18
FAKE_TCP_LISTEN and the ports specified.
20
Note that all options apart from -p are ignored.
30
_temp=$(getopt -n "$prog" -a -o "np:" -l help -l PS: -l oG: -- "$@")
40
-p) ports="${ports}${ports:+ }${2//,/ }" ; shift 2 ;;
42
-h|--help|*) usage ;; # * shouldn't happen, so this is reasonable.
48
[ -n "$ports" ] || usage
59
pn=$(getent services "$p" | sed -e 's@[[:space:]].*@@')
60
for i in $FAKE_TCP_LISTEN ; do
62
if [ "$p" = "$lp" ] ; then
63
port_states="${port_states}${port_states:+, }${p}/open/tcp//${pn}///"
67
port_states="${port_states}${port_states:+, }${p}/closed/tcp//${pn}///"
71
# Nmap 5.21 scan initiated $(date) as: nmap $args
72
Host: 127.0.0.1 () Status: Up
73
Host: 127.0.0.1 () Ports: $port_states
74
# Nmap done at $(date) -- 1 IP address (1 host up) scanned in 0.04 seconds