#!/bin/bash tmp=/root/usbclients waitt=10 while true do ALLCLIENTS=$(find ${tmp} -type f | sort) for i in ${ALLCLIENTS} do client=$(basename ${i} .txt) dev=$(< ${i}) if fping -q -t50 ${client} then echo "-- polling client ${client} on dev ${dev}" usbip -a ${client} ${dev} else echo "-- client ${client} not found, removing from list" out=$(mktemp) port=$(portusbip -p &> ${out};grep -B3 -i "128.20.3.3" ${out} | grep Port | cut -d' ' -f2| sed "s|:||") usbip -d ${port} rm ${out} rm ${tmp}/${client} fi sleep $waitt done done