Skip to content

Instantly share code, notes, and snippets.

@scottlee
Last active December 26, 2015 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottlee/7222328 to your computer and use it in GitHub Desktop.
Save scottlee/7222328 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Get IP address from output file in Dropbox.
ip=`cat ~/Dropbox/HomeNetworkIP.txt`
# Establish SSH session
ssh $ip
# To connect:
# ./Dropbox/scripts/connect_to_home.sh
#!/bin/bash
# Specify output file for IP address here.
ip_file=HomeNetworkIP.txt
# --------------------------- #
# Let's get down to business
# --------------------------- #
# Get current IP address
current_ip=$(curl -s http://icanhazip.com)
# If the IP file exist, grab the old IP address
if [ -f "$ip_file" ]
then
old_ip=$(<$ip_file)
fi
# If current IP address is NOT the same as the old update the IP file.
if [ $current_ip != $old_ip ]
then
echo $current_ip > $ip_file
else
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment