The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
MPAA Sets Up Fake Site to Catch Pirates - Slashdot iBot UNIX and Linux RSS News 0 07-07-2007 05:10 PM
system Fake IPs ppass SUN Solaris 2 04-26-2005 09:33 AM
Static wojtyla High Level Programming 6 02-25-2005 07:57 AM
Fake System32 Folder Kimm Linux 2 08-23-2004 07:25 AM
Static IP google IP Networking 7 05-18-2003 04:33 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-21-2007
heith's Avatar
Registered User
 

Join Date: Feb 2007
Location: Michigan, USA
Posts: 3
Exclamation Fake Static IP... (shell script)

I'm working on a script that runs on remote hosts and sends their dynamic IP address' to a server (which of course has statics).

All the client computers run linux (as does the server).

basically... the idea was:

1) Host a webpage on the server with a php script that displays only the IP address of the client.
I accomplished this with code: <?php echo $_SERVER['REMOTE_ADDR']; ?>

2) run a script (in a cron job) that queries the the server for its current IP, then checks it against the the last known IP. If its changed, it sends the updated IP address to the server. (the use the lynx domain.com/ip --dump command to get my public IP)


-- So... I have two questions. (maybe more)...


1) What do you guys think the best solution is to get the IP and hostname back to the server? I have shell access to all computers, so I thought scp at first... but a few of the computers have users I don't necessarily trust, so I really didn't want to use scp in a script...

2) I also would like to make a url forward to that computer... How can I for example:
"ssh user@domain.com/remote1" and have the php script (or any kind of script) redirect (...route) me to the remote hosts IP?

This is something I've been working on for a while... I realize it may not be the most elegant approach, but its what I came up with after much, much deliberation. So any Ideas... experinces... advise will be greatly appreciated!

Btw, This might be the first time I've ever posted an actual question about linux or anything for that matter. I can always find the answers I need by searching and reading... even if it takes weeks to figure out one little thing. So I wouldn't ask If I felt I could just google it and find the answers.

Last edited by heith; 02-21-2007 at 10:01 PM. Reason: add icon so I would draw your attention :)
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-22-2007
heith's Avatar
Registered User
 

Join Date: Feb 2007
Location: Michigan, USA
Posts: 3
fsip

Did I post this in the right section?

I've been checking these forums every 3 hours for days... Reading these forums I can tell there are a lot of crazy smart people here... can just one of you through me a bone?

Last edited by heith; 02-25-2007 at 02:44 AM. Reason: need help...
Reply With Quote
  #3 (permalink)  
Old 02-27-2007
heith's Avatar
Registered User
 

Join Date: Feb 2007
Location: Michigan, USA
Posts: 3
The Script...

ok, I don't think I explained it well enough.

I think it will be easier if I just paste the script... then you can pick it apart.

Code:
#!/bin/bash
BASEDIR=~/scripts/fsip	##The name of the folder you keep all your text files 
NEWIP=$BASEDIR/newip	##Location of the text file that will store the address of the CLIENT
SERVER=example.com       		##Name of the server that hosts the IP   	
RHOME=/home/fsip/ 	##Target Directory on the server (the location of the SERVER script)   	
GETIP=example2.com/ip		##The server[s] that send back the Clients public IP. (calls a webpage with this php code: <?php echo $_SERVER['REMOTE_ADDR']; ?>)
PUBIP=`lynx -dump $GETIP`	##Getting the CLIENT's current ip address  (of course this requires lynx... elinks should work too)
#-----------------------------------------------------------------------------------------------
if [ "$PUBIP" != "$NEWIP" ]; then
echo $PUBIP > $NEWIP
scp $NEWIP $SERVER:$RHOME/`hostname`-ip.txt
fi
---------------EDIT------------------

If anyone cares... (which I doubt because no one took the time to respond) I
came up with a better solution with the help of a php guru.

If you interested in a fake static IP, email me.

Last edited by heith; 03-02-2007 at 06:41 AM. Reason: typo
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:01 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0