tkevans@fallst.UUCP (Tim Evans) (07/19/88)
For reasons unknown, the vendor at our site (also to be unknown) chose to process mail addressed outside our network (that is, uucp mail containing 'bangs') with a shell script which parses the address using the following, then submits the message via stdout to 'uux'. "ARG" is the full mail address; "HOST" is the first system name in the address; "NAME" is the user name to which the mail is finally addressed (i.e., the last field in the address) ----------------------------------------- NAME=`echo "$ARG" | sed "s/.*!//g"` HOST=`echo "$ARG" | sed -e "s/![^!]*$//g"` [ some sed stuff placing "$ARG" in a temp file, with stdout piped to 'uux' ] uux - "${HOST}!rmail ${NAME}" ---------------------------------------- This works fine as long as there is only ONE 'bang' in the address, but when the address contains more than one 'bang' it creates malformed uucp work files which are rejected by the first system in the address. Assuming the address "system1!system2!system3!user" this script results in a "X." file being sent to system1 containing the following line: C rmail!system2 system3!user The proper line should, of course, be: C rmail system2!system3!user Below is a rewrite which I did, hoping to fix up this problem. Does anyone have comments or suggestions to improve it? "ARG" "HOST" and "NAME" are the same as above; "HOPS" extracts the intervening hops in the address (between "HOST" and "NAME") ---------------------------------------------------------- HOST=`echo "$ARG" | awk -F"|" '{ print $1 }'` HOPS=`echo "$ARG" | awk -F"|" ' BEGIN { ORS = "!" } { # use bang as output separator for (i = 1; i <= NF - 1; i++) { # no bang after last sysname if ($i != $1) { print $i } } }'` NAME=`echo "$ARG" | awk -F"|" '{ print $NF }'` # test for null string "HOPS" (only one bang in address) if [ -z "$HOPS" ] then ADDR="${NAME}" else ADDR="${HOPS}!${NAME}" # last bang added here fi [ some sed stuff placing "$ARG" in a temp file, with stdout piped to 'uux' ] uux - "${HOST}!rmail (${ADDR})" ----------------------------------------- Thanks -- ...!{rutgers|ames|uunet}!mimsy!aplcen!{wb3ffv!fallst|woodb}!tkevans ...!attmail!fallst!tkevans 2201 Brookhaven Court, Fallston, MD 21047 (301) 965-3286