WAN interface configured with DHCP so address is changing constantly. Wanted to build a script that would determine IP address and upload to remote server using sftp or scp.
This is incomplete right now, it lacks the upload ability.
Schedule script to run every every 15 minutes using cron.
#!/bin/bash # Print layer 2 and 3 interface statistics to file ifconfig pppoe0 > pppoe.txt #Find line that includes IP addresses, remove pppoe.txt awk '/inet/' pppoe.txt > addresses.txt rm pppoe.txt # Print 2nd field awk -F: '{print $2}' addresses.txt > address.txt # Remove addresses.txt, no longer needed rm addresses.txt # Extract IP address from string temp=$(<address.txt) echo "$temp" | grep -o '[0-9]*.[0-9]*.[0-9]*.[0-9]* ' # Remove address.txt, no longer needed rm address.txt