#! /bin/perl ################################################################################ # hserv v0.91 3-31-96 Dale Bewley # hserv v0.90 8-06-95 #------------------------------------------------------------------------------# # This script and others found at http://www.bewley.net/perl/ # # This program will reguire modification if used outside of IUPUI. # # Requires my pip script. Updates a HTML document so it will point to your # webserver connected via PPP each time you run it. # Would be a good idea to put this in your .cshrc and it will be updated # automatically. You should not put it in crontab until I have a sure way # to pick your PPP login, not just the first one in `who`. # # See http://www.iupui.edu/~dbewley/home-serv.html for a demo. # # Notes: # o If you would like a page to link to your home server automatically, add # the following to the head of the page. # # # # o You can use this to update all the links on a page. For example, # besides the META line, I have a cool talk link like this: # # http://live.netscape.com/cgi-bin/411invite.cgi?address=dbewley@134.68.249.42 # # o pip needs a re-write -- especially if you use this at another site. # ################################################################################ # how do you use this thing? if (!$ARGV[0]) { print "Usage: $0 username [filename]\n"; print "\tDefault filename is $ENV{\"HOME\"}/public_html/home-serv.html\n"; } else { chop($ip=`pip $ARGV[0]`); if ($ip) { if (!$ARGV[1]) { $ARGV[1] ="$ENV{\"HOME\"}/public_html/home-serv.html";} open (HTML, "$ARGV[1]") || die "I can't open: \"$ARGV[1]\"!, Stopped"; open (OUTFILE, ">$ARGV[1].tmp"); while () { $_ =~ s#(.+)(\d{3}\.\d+\.\d+\.\d+)(\D.+)#$1$ip$3#; print (OUTFILE); } unlink ($ARGV[1]); rename ("$ARGV[1].tmp", $ARGV[1]); chmod 0755, $ARGV[1]; } else { print "Nothing done. $ARGV[0] may not be logged in via PPP."; $alternant = (`who | egrep '(x2s|134.68.249)' | grep $ARGV[0] | awk '{print $2}'`); print "\n"; print " Try \"hserv $alternant\".\n"; } }