Nice easy little script there, acummings .. here's what I've done with it:
On my static IP, I put a tiny php file out there called "serverinfo.php"
Code:
<?php
echo $_SERVER["REMOTE_ADDR"];
?>
Now, from the box in my house that has the dynamic IP, I run:
Code:
curl -s http://(mywebsiteonstaticIP)/serverinfo.php
Which gloriously returns my dynamic IP. I wanted something of my own out there so if it stops working (aka, if "what's my ip" goes down, I won't have to rebuild), I can fix it myself and won't be reliant on others.
simple ... now that you've helped me figure out what all this stuff is!
Here's the question, though, and I think demonbane, you were trying to tell me this, but I still don't quite get it.
I also have a script out there called "info.php" that just returns the following:
Code:
<?php
phpinfo(INFO_VARIABLES);
?>
Now, when I look at this, the _SERVER["HTTP_CLIENT_IP"] variable has the correct IP and _SERVER["REMOTE_ADDR"] has an incorrect IP ... in fact, I have no idea what that IP actually is.
However, when I use this curl script, it brings back the correct ip ... the one that was reflected on the HTTP_CLIENT_IP var.
I guess I'm wondering what these variables are actually pulling.
As an example:
I use any web browser and go to my static IP
>
http://(mywebsitewithstaticIP)/serverinfo.php
I get back some number that I don't know ... say 67.198.37.58
Now, I do this:
# curl -s
http://(mywebsitewithstaticIP)/serverinfo.php
> correct IP address
#
what's going on there? Why does browsing to the php file return one IP for REMOTE_ADDR and using curl returns a different one?
Question 2:
Now I've got this working ... what should I be looking at to create something that will either
a) ftp a file to my static IP containing my dynamic IP that I've just received
b) write to a file on that static IP site (btw, controlled by someone else ... I simply have ftp access)
Another phrasing of that question: is there a way to hard code an ftp transfer of a file? I could make a script that opens ftp at the correct address ... but once ftp is open, I don't know how to use a script to write in password and username or the file transfer "put" process.
........90% there
Thanks for all the help so far!