خرید بک لینک

I'm trying to write a bash script for my server. What this script does is runs curl to get the latest ip address of my box and then email me if it's different from the old ip address stored in a file.

This is what I have now:

#!/bin/bash
#if ip address changes do
x=$(curl -4 "icanhazip.com")
y=$(cat ./oldIP.txt )
if [ "$x"!="$y" ];
    then
    echo "Current IP Address is $x"
    echo "Previous IP address is $y"
#   y=$x
elif [ "$x"="$y"]
    then
    echo "The IP addresses are the same"
fi
#send email to me

I tried using if; then; else; as well however I caot get the script to react differently when the ip addresses are the same.

I believe the issue stems from my variable declaration for $y.

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 29 فروردين 1395 ساعت: 2:50

صفحه بندی