|
|
|
|
#1 |
|
Triple-A Player
Join Date: Jun 2003
Posts: 63
|
I am trying to write a script that I can run as a cron job that will email my IP address to me at work. I realize there are shareware products out there that do the job but I need to be able to modify some things. Does any one have a script that will return my IP address.
Running 10.2.6 Thanks |
|
|
|
|
|
#2 |
|
Moderator
Join Date: Jan 2002
Posts: 10,652
|
__________________
Chameleon's Consignment Loft] |
|
|
|
|
|
#3 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
here's gip and dhtml:
Code:
#!/bin/sh
# file: gip -- get current public IP address and ftp it up
#set -xv
prog=`basename $0`
curl=/sw/bin/curl
cut=/sw/bin/cut
dhtml=~/bin/dhtml
egrep=/sw/bin/egrep
tee=/usr/bin/tee
ftp=/usr/bin/ftp
logger=/usr/bin/logger
curip=~/curip
checkIPurl='http://checkip.dyndns.org/'
grepStr="address|hostname"
ftpSite="ftp.mindspring.com"
set +o noclobber
${curl} -s ${checkIPurl} | ${dhtml} | \
${egrep} -i "${grepStr}" | ${tee} ${curip}
# ~/.netrc contains machine info for ftp site
${ftp} ${ftpSite} <<__end_ftp
put ${curip} curip
quit
__end_ftp
evHostIP=`${egrep} -i address ${curip} | ${cut} -d" " -f4`
export evHostIP
${logger} -i -p local3.info -t ${prog} "ip posted: ${evHostIP}"
# --------------- here's dhtml ------------
#!/usr/bin/perl -w
# file: dhtml - strip html tags
while (<>) {
$_ =~ s/<[^>]*>//g;
print;
}
|
|
|
|
|
|
#4 |
|
Moderator
Join Date: Jan 2002
Location: Montreal
Posts: 29,279
|
macosxhint
There was a recent MacOSXHint on this very topic:
http://www.macosxhints.com/article.p...30607094823255 Check out the comments to this hint as well - I contributed a script (similar to that of mervTormel's) that gets your IP addres via an external site. |
|
|
|
|
|
#6 |
|
Triple-A Player
Join Date: Jun 2003
Posts: 63
|
I saw the recent hint:
http://www.macosxhints.com/article....030607094823255 But the actual script seems to be missing. The author calls /Users/me/scripts/getip | mail -s "my IP at home" myemail@work.com What's "getip" ? I am assuming that if I had the script "getip" I would have my answer. Any clues?
|
|
|
|
|
|
#7 |
|
Major Leaguer
Join Date: Nov 2002
Location: Montréal, QC, Canada
Posts: 329
|
that was his first method of automatically obtaining his IP address at home from work. basically, via cron, it auto-sends the IP every morning.
you should take more interest in the second half of that hint only... what IT allows you to do is email yourself at home, Mail.app will check that mail for a keyword you have set up in a rule in mail's prefs, and if that word is there, it will run the applescript that's in the second part of that hint. *edit* i didn't read that second part too thoroughly. it DOES call that script in BOTH parts of the hint. sorry for that. *end edit* Last edited by jdhorner; 06-18-2003 at 07:06 PM. |
|
|
|
|
|
#8 |
|
Site Admin
Join Date: Dec 2001
Location: Portland, OR
Posts: 1,441
|
The URL for the "getip" script is in the hint, too:
"Credits: All props go to Jerry LeVan for his excellent perl script to fetch the ..." -- "perl script" is linked to the getip script. -rob. |
|
|
|
|
|
#9 |
|
Major Leaguer
Join Date: Nov 2002
Location: Montréal, QC, Canada
Posts: 329
|
ahh, edit, part 2. but later down, in the comments on that hint, you can find a few different takes on some scripts that you can use as your own "getip" script.
|
|
|
|
|
|
#10 |
|
Major Leaguer
Join Date: Feb 2003
Location: Berkeley, CA
Posts: 270
|
You can also get your current IP address this way:
Code:
ipconfig getifaddr en0 Code:
192.168.250.16 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|