Last week I need to find the IP of my UPnP mediaserver in a console environment.
I didn’t find a small to get only the IP, so I wrote this small script that uses the GUPnP.
find_upnp_mediaserver_ip.sh
#!/bin/sh
DISCOVER="/usr/bin/gssdp-discover"
check_discover()
{
if [ ! -f $DISCOVER ]; then
echo "$DISCOVER not found. Please install gupnp-tools"
exit 1
fi
}
find_ip()
{
$DISCOVER -n 5 --target=urn:schemas-upnp-org:device:MediaServer:1 |
grep -o -E '([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}\.([0-9]){1,3}'
exit 0
}
## main
check_discover
find_ip