#!/bin/sh # The script helps you with the programm 'redirect'. With this program you can access a host via another. # # Autor Thorsten Gunkel # # Syntax: my_redirect Host_youre_interessted_in temp_port # Example: www.bib.informatik.th-darmstadt.de 1115 # would allow access to www... via port 1115 on the machine where this script is started # # Try to find out your hostname. Don't know if who -l is the best way to do it. your_name=`whoami` yourhost_name=`who -l | grep "$your_name" | sed s/.*\(// | sed s/\).*// | tail -1` # Try to find out the official name of localhost. Sadly some hostname version are quite stuipd gate_name=`hostname` gate_port="$2" # http as dest_port seems a commen default dest_name="$1" dest_port=80 # Tell the user what happens echo "This Script uses 3 Hosts." echo echo "1. The host where you are." echo " -> I think this is: $yourhost_name." echo echo "2. The host where this script is started." echo " -> I guess this is: $gate_name." echo " You have to tell this script as the 2. parameter a port at this host you can access to." # No I'm not mad, some test versions are if [ "X$gate_port" = "X" ]; then echo " *** As you didn't specify a 2. paramter I will select one for you. ***" gate_port="1122" fi echo " -> I will use: $gate_port." echo echo "3. The host you want acces via 2. This is the 1. parameter this script expects" # Again, blame test not me if [ "X$dest_name" = "X" ]; then echo " *** As you didn't specify a 1. paramter I will select one for you. ***" dest_name="www.bib.informatik.th-darmstadt.de" fi echo " -> I will use: $dest_name." echo " -> port: $dest_port". echo # This should make things clear echo "In short: $yourhost_name can access $dest_name:$dest_port via $gate_name:$gate_port" echo # That's all redirect $yourhost_name $gate_port $dest_name $dest_port