linux-l: ip-adresse extrahieren

Wolfgang Conrad coney at praxisarzt.de
Fr Mai 26 21:00:02 CEST 2000


oder folgendes script von Greg Hunt 
                                             
Download at                                    http://www.loop.com/~vipvop/dynip.expect 




#!/usr/bin/expect -f
# TCL/expect script to automagically update a web page with your IP address
# by Greg Hunt <vipvop (at) loop.com>
#

set file "/tmp/vipvop-ip.html" ;# temp file to be created
set ifconf "/sbin/ifconfig"    ;# location of ifconfig
set name "vipvop-ip.html"      ;# name of file to be created on server
set ftp_host "ftp.loop.com"    ;# ftp host
set ftp_user "username"          ;# your user name
set ftp_passwd "secret"     ;# your password
set desc "Cacophony"           ;# description of your computer

#the following gets your IP address from ppp0
set ip [exec $ifconf ]
set indx [string last "addr" $ip]
set indx [expr $indx + 5]
set ip [string range $ip $indx end]
set indx [string first " " $ip]
set indx [expr $indx - 1]
set ip [string range $ip 0 $indx]
#end - ip now hold your ip address

#this gets the current date and formats it
set systime [clock seconds]
set datestrng "Last updated: [clock format $systime -format %H:%M:%S] - [clock format $systime -format {%B %d, %Y}]"
#datestrng now holds the formatted string

#this generates the page - change the title and anything else
set toout [open $file w]
puts $toout "<HTML>\n<HEAD>\n<TITLE>$desc</TITLE>"
puts $toout "<meta http-equiv=REFRESH content=\"2; URL=http://$ip\">"
puts $toout "</HEAD>"
puts $toout "<center><font size=+2>$desc</font></center>"
puts $toout "<br>\n This page will take you to $desc in 2 seconds, if you"
puts $toout "are having problems click <a href=\"http://$ip\">here</a>."
puts $toout "<hr>\nThis page generated by dynip.expect<br>"
puts $toout $datestrng
puts $toout "</HTML>"
close $toout
#page has been generated

spawn ftp $ftp_host
expect "Name*:"
send "$ftp_user\r"
expect "Password:"
send "$ftp_passwd\r"
expect "ftp>"
send "put $file $name\r"
expect "ftp>"
send "quit\r"
close

file delete $file
puts "\n"



-- 

Wolfgang Conrad      c at coney.de   http://www.coney.de



Mehr Informationen über die Mailingliste linux-l