You are not logged in.
I wrote a crude unix utils based script that attempts to parse the output of a nmap network scan. The goal is to show some basic stats of connected devices, ip address, hostname, comments, etc.
5E:D0:2B:5C:EC:2C 192.168.1.3 Netgear
A8:27:AB:8D:B0:11 192.168.1.101 firewall Raspberry Pi Foundation
EA:CC:AF:E1:21:2A 192.168.1.102 pi-hole (unknown)
I found in the nmap man page the ability to write the scan results to an xml file which should allow for proper parsing but the xml tools are new to me. Can someone recommend a proper syntax to replace my awk/sed hacky script proper calls to xmllint or a like too?
My script: https://github.com/graysky2/bin/blob/ma … sconnected
Example xml: https://gist.github.com/graysky2/8e7f01 … d61017c05e
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
Something like this?
xmllint testxml --xpath '//hostnames/hostname/@name'
Offline
Ah, getting closer... In order to read them into an array (bash), the output would need to be clean hostnames though. I can obviously use awk or similar but that would defeat the purpose of using the xml utils.
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
xmlstarlet sel -t -v '//hostnames/hostname/@name'
Offline