![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| comparing 2 string variables in unix | katdaniel16 | UNIX for Dummies Questions & Answers | 17 | 07-23-2008 03:25 AM |
| comparing content of 2 variables in script | sam4now | Shell Programming and Scripting | 5 | 04-24-2008 03:42 PM |
| Comparing two variables | rajip23 | Shell Programming and Scripting | 3 | 04-11-2008 06:45 AM |
| Sed grabbing the last line of a file | xgringo | Shell Programming and Scripting | 2 | 03-24-2008 09:24 PM |
| comparing variables | MizzGail | UNIX for Dummies Questions & Answers | 3 | 02-08-2008 01:53 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Grabbing variables and comparing
I have two computers with dynamic IP addresses and am using dyndns so that they are identifiable as the same computer even if their IPs change (we'll call them host1.dyndns.com and host2.dyndns.com). I also have a remote server which I would like to store my computers' IP addresses on. There is a file on my remote server which has the IPs that the two hostnames point to. So the file would look like this
111.111.111.111 #host1.dyndns.com 222.222.222.222 #host2.dyndns.com I need a script that will run this command which gets the IPs of my computers: /usr/bin/dig +short host1.dyndns.com | /usr/bin/tail -n 1 /usr/bin/dig +short host2.dyndns.com | /usr/bin/tail -n 1 Then compare the result (which is an IP address) to the file that I have described above. If the IP is different from the old one then remove that line and replace it with the new IP. I thought I could do this myself but grabbing the old IP and storing it in a variable and then comparing it to the new IP was beyond me. I don't even know if that is how you should do it. sed/awk is preferable but any language will do ![]() Thanks in advance. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|