bash - parsing a csv file $INPUT, write to $OUTPUT, and prompt for user input all in a while loop - user NOT prompted -
i have problem, , pretty new writing bash. parsing csv file, checking few things. if check true, change variable later written file. reading input file , outputting file well, , if argument checks true, want prompt user , pause script until user verifies information matches (manual verification).
i have recent attempt not prompting. continues read , write output. pretty sure because output going directly output file, not know way direct prompt terminal window stuck.
input=$tmpsave ifs=, [ ! -f $input ] && { echo "$input file not found"; exit 99; } while read cdwon cdwod manu_date hp_sn manu_sn wiped_by wiped_date checked_by disposition readonly in ${!allassigned[@]} if [[ -n $manu_sn ]] if echo ${allassigned[i]} | grep -q $manu_sn physicaldrive=${allassigned[i-1]} disk=$(hpacucli ctrl slot=${slot} show config detail | grep -b 4 ${physicaldrive} | head -1 | awk '{print $nf}'); if [[ -n $disk ]]; #proceed wipe drive mount ${disk}${primary} ${mount} if [ -e $dir ]; ####### file exists, it? automatcially prompt user? cat $dir > /dev/tty echo "does drive serial number (${allassigned[i]}) match provided database ($manu_sn)? (y/n)" > /dev/tty read if [ "$reply" == "y" ] || [ "$reply" == "y" ] || [ "$reply" == "yes" ] || [ "$reply" == "yes" ]; checked_by=$username checked_bydate=`date` fi fi fi fi fi done echo "$cdwon,$cdwod,$manu_date,$hp_sn,$manu_sn,$wiped_by,$wiped_date,$checked_by,$disposition,$readonly"; continue; done < $input > $output
i solved own issue here. found out read default reading stdin. when trying prompt input using stdin, lines reading technically stdin input. if want read file in while loop method have done have change fd so:
while read -u 6 column1 column2 .....body done 6< $inputfile
key being "6" arbitrary number.
Comments
Post a Comment