Skip to content

Instantly share code, notes, and snippets.

@alex-pat
Created March 8, 2017 14:09
Show Gist options
  • Save alex-pat/cb59e8ce97044d28920abc546f8c55ac to your computer and use it in GitHub Desktop.
Save alex-pat/cb59e8ce97044d28920abc546f8c55ac to your computer and use it in GitHub Desktop.
Raspberry Pi
#!/bin/bash
# sends ip to all devices in local network
PORT=3001
C_IP=$(ifconfig wlan0 | grep -oe 'addr:192.168.[[:digit:]]*' | cut -d. -f 3 )
COMPS=$(nmap 192.168.$C_IP.1/24 | grep "scan report" | grep -v raspberrypi | grep -oe '(192.168.[[:digit:]]*.[[:digit:]]*' | cut -d. -f4 )
for i in ${COMPS[@]}
do
echo "ip of pi is $(hostname -I)" | netcat "192.168.$C_IP.$i" "$PORT"
done
#!/bin/bash
# Run it first
PORT=3001
MY_IP=$(ifconfig -a | grep -oe '192.168.[[:digit:]]*.[[:digit:]]*' | head -n 1 )
ncat -l "$MY_IP" "$PORT"
ncat -l "$MY_IP" "$PORT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment