#!/bin/bash processLine(){ line="$@" # get all args traceroute -I -z 5 -w 2 $line } ### Main script stars here ### # Store file name FILE="" # Make sure we get file name as command line argument if [ "$1" == "" ]; then echo "Usage: fqdn_traceroute.sh filename"; exit 0; else FILE="$1" # make sure file exist and readable if [ ! -f $FILE ]; then echo "$FILE : does not exists" exit 1 elif [ ! -r $FILE ]; then echo "$FILE: can not read" exit 2 fi fi # read $FILE using the file descriptors # Set loop separator to end of line BAKIFS=$IFS IFS=$(echo -en "\n\b") exec 3<&0 exec 0<"$FILE" while read -r line do # use $line variable to process line in processLine() function processLine $line done exec 0<&3 # restore $IFS which was used to determine what the field separators are IFS=$BAKIFS exit 0