1#!/bin/sh 2 3: ${FTP:=ftp} 4 5: ${rport1:=9000} 6: ${rport2:=9001} 7 8req1=$1 9loc=$2 10req2=$3 11 12echo "Testing $req1 => $loc => $req2" 13 14# Be sure to kill any previous nc running on our port 15while pkill -fx "nc -l $rport1" && sleep 1; do done 16 17echo "HTTP/1.0 302 Found\r\nLocation: $loc\r\n\r" | nc -l $rport1 >&- & 18 19# Give the "server" some time to start 20sleep .1 21 22res=$(${FTP} -o/dev/null $req1 2>&1 | sed '/^Redirected to /{s///;x;};$!d;x') 23 24if [ X"$res" != X"$req2" ]; then 25 echo "*** Fail; expected \"$req2\", got \"$res\"" 26 exit 1 27fi 28