[perl] dynamisch ip script.

Pagina: 1
Acties:
  • 35 views sinds 30-01-2008

  • digit7722
  • Registratie: Juni 2001
  • Laatst online: 27-11-2018

digit7722

Rule # 217

Topicstarter
Ik heb zelf een prachtig perl script geschreven wat je lokale ip in een html file gooit en vervolgens dat filetje upload naar een ftp site (ips home site).
dit zorgt ervoor dat je server met een dynamisch ip toch altijd te benaderen is via 1 url (bv: home.quicknet.nl/pietje/redir.htm).
Perl:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/perl
#Dynamic ip dns script.
#Created by Digit 2/20/2003

#all the modules i use for this puny little script shees 3 of them
use Sys::Hostname;
use LWP::UserAgent;
use Net::FTP;

#ftp credentials please modify to suit your own needs.
$username = "micky_mouse";
$password = "minnie";
$address  = "home.disney.com";

#html file name, you could call it index.htm or whatever you prefer.
$filename = "redir.htm";

print "Please wait fetching ip-address.\n";
($name,$aliases,$addrtype,$length,@addrs) = gethostbyname(Sys::Hostname::ghname());
    ($a,$b,$c,$d) = unpack('C4',$addrs[0]);
     $ip = "$a.$b.$c.$d";
print "$ip\n";
open (FILE, "> $filename")      or die "Cant create $filename: $!";
print FILE "<HTML>\n";
print FILE "<HEAD>\n";
print FILE "<TITLE>Digits redirect script. </TITLE>\n";
print FILE "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0; URL=http://$ip:8080\">\n";
print FILE "</HEAD>\n";
print FILE "<BODY bgcolor=#000000>\n";
print FILE "<center>\n";
print FILE "<font color=#55ff55 size=24><b>Redirecting.</b></font>\n";
print FILE "</center>\n";
print FILE "</BODY>\n";
print FILE "</HTML>\n";
close (FILE);

print "Connecting to $address\n";
$ftp = Net::FTP->new($address) or die "Can't connect: $@\n";
print "Logging in as $username\n";
$ftp->login($username, $password) or die "Couldn't login\n";
print "uploading $filename now\n";
$ftp->put($filename) or die "Couldnt upload $filename\n";
print "all done upload of $filename complete.";


ja dit is schaamteloos pochen, maar ik doe het meer omdat ik zelf perl heb geleerd puur om dit voor elkaat te krijgen.
mischien dat ik op deze manier een ander die moeite kan besparen ;)

You can't free a fish from water.


  • Spider.007
  • Registratie: December 2000
  • Niet online

Spider.007

* Tetragrammaton

hier hebben we hotscripts voor? Verder zwerft er ook ergens een "Post hier je script" topic rond. Maar hij is mooi hoor :)

---
Prozium - The great nepenthe. Opiate of our masses. Glue of our great society. Salve and salvation, it has delivered us from pathos, from sorrow, the deepest chasms of melancholy and hate


  • Glimi
  • Registratie: Augustus 2000
  • Niet online

Glimi

Designer Drugs

(overleden)
Netjes hoor :) Vooral omdat ik het begrijp en perl niet ken (terwijl perl als write only bekend staat :+) maar 'iets ermee kunnen' in P&W zit er niet echt in, sorry. :)

Als je het graag toch wilt posten om er bijv commentaar op te krijgen, dan raad ik http://www.codebase.nl aan, of http://www.hotscripts.com
Ik wens je er veel succes mee :)

Dit topic is gesloten.