Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > adv IP Report

adv IP Report
Thread Tools
Dedicated MacNNer
Join Date: Apr 2001
Location: The Moon
Status: Offline
Reply With Quote
Sep 6, 2003, 06:54 AM
 
Hi,

Could somebody please help out me with a script. It should

1) Check if DHCP is up (not 169.xx.xx.xx), if not release and re-init the DHCP, if IP has changed ->2

2) Report IP to a FTP.server

well here is why ...

The problem with my ISP (Cable) is that from time to time (weekly) they shutdown a router or something so my DCHP connection is dropped and OS X is assigning an ip itself (169.xx.xx.xx). No Problem if I am around. But what if I am away ? Even-worse they changed afterwards my IP to something different ...
(Last edited by Samanoske; Sep 6, 2003 at 07:47 AM. )
.- OS X aDDICTED -.
     
Dedicated MacNNer
Join Date: Apr 2001
Location: The Moon
Status: Offline
Reply With Quote
Sep 6, 2003, 06:56 AM
 
Ok I know how to renew the DHCP,

sudo ipconfig set en0 BOOTP
sudo ipconfig set en0 dhcp

but I have no idea how to compare the ip
.- OS X aDDICTED -.
     
Dedicated MacNNer
Join Date: Apr 2001
Location: The Moon
Status: Offline
Reply With Quote
Sep 6, 2003, 02:27 PM
 
Ok .. after a small fight with the csh shell, and I have to admit the Manuals on the net are very helpful - I succeeded

what do you think to my little script ...

#!/bin/csh

ipconfig getifaddr en0 > IP
set uno = `awk -F . '{print $1}' IP`
echo $uno" as first IP Numba"

if ( $uno == '192') then
echo "We Are Laned"
else if ( $uno == '169') then
echo "We don't have a DHCP Connection"
echo "tryin to re-establish"
while ( $uno == '169')
sudo ipconfig set en0 BOOTP
echo "tryin to reach DHCP Server in few sex"
sleep 3
sudo ipconfig set en0 DHCP
sleep 12
ipconfig getifaddr en0 > IP
set uno = `awk -F . '{print $1}' IP`
end
echo "We have a Connection back"
echo "Copying IP to FTP Server"
ncftpput -E -u <Login> -p <Password> <Ftp.Server> <ServerFolder:/IP/> <File:IP>
endif


ofcorse I get rid of the echos for the the final-cron-job-script but they helped to script it










Report this post to a moderator | IP: Logged
     
Dedicated MacNNer
Join Date: Mar 2000
Location: Bronx, NY 10471
Status: Offline
Reply With Quote
Sep 6, 2003, 07:52 PM
 
i know this is a little off-topic of unix, but why dont you use something like dyndns.org. Check it out

Mel
     
Dedicated MacNNer
Join Date: Apr 2001
Location: The Moon
Status: Offline
Reply With Quote
Sep 7, 2003, 04:41 AM
 
Originally posted by melman101:
i know this is a little off-topic of unix, but why dont you use something like dyndns.org. Check it out

Mel
Originally posted by Samanoske:
The problem with my ISP (Cable) is that from time to time (weekly) they shutdown a router or something so my DCHP connection is dropped and OS X is assigning an ip itself (169.xx.xx.xx).
Well if the connections is dropped and I have a selfassigned IP, I can not report any IP.
.- OS X aDDICTED -.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 10:22 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2