Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Dynamic IP: remote notification of changes, automatically updated information< Next Oldest | Next Newest >
gjhicks Offline





Group: Members
Posts: 108
Joined: April 2004
Posted: Mar. 03 2006,12:42 QUOTE

Hi,

Like many other ADSL users, I do not have a static IP, with my ISP changing my IP address at a irregular intervals.

Using 'ssh' with a redirected port and WinSCP, I can access my DSL server remotely.  One problem - how to know the current IP address of the DSL server?

Below is my solution:

1) Install 'cron' (use apt-get)

2) Use cron to call the following script (I am sure the script could be more elegant but I am just a beginner):

#!/bin/bash
#
# Get the current external IP address of the DSL server,
# via the 'whatismyip' webpage

wget -q http://www.whatismyip.com/

# Get just the first line, that is the string containing the IP address,
# then trim from the left to remove the html formatting

grep '<title>WhatIsMyIP' index.html | \
awk '{ d = length($3); print substr($3, 1, d-8) }' > tmp1

# Get the current DSL server time and construct the output string

STR1=$(date)" - DSL Server: Current IP Address = "$(cat tmp1)

# Write the string to a file

echo $STR1 >myip.txt

# Use the command line ftp to send the file to a server,
# using .netrc to automate the process

ftp ftp.servername.com

# clean up
rm index.html
rm tmp1

3) Contents of /home/dsl/.netrc

machine ftp.servername.com
login ftp-username
password mypassword
macdef init
prompt
hash
lcd /home/dsl
cd public_html
mdelete myip.txt
put myip.txt
quit
# newline terminates macro

4) Crontab contents

0 2,6,10,14,18,22 * * * /home/dsl/myip.sh

The above instruction runs the myip.sh script every 4 hours from 2am.

By the way, to create or edit the crontab instruction file, you need to set up the editor used by crontab, which defaults to /usr/bin/editor.  I made a symbolic link to /bin/nano.

The end result is that, entering the URL to the text file in a browser, I get the current IP address for the DSL server.

------------------------------------------------------------------------------------------



BUT, I would much rather email the text file but I can not get a command line email agent to work in DSL.

Can anyone help me figure out how to get a command line email agent working in DSL?

Thanks

Geoff.
Back to top
Profile PM 
0 replies since Mar. 03 2006,12:42 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: Dynamic IP: remote notification of changes

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code