Skip to content

Instantly share code, notes, and snippets.

@roelandp
Created November 29, 2018 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roelandp/4f9e9677e9210dcddb7fa845f5e8d8af to your computer and use it in GitHub Desktop.
Save roelandp/4f9e9677e9210dcddb7fa845f5e8d8af to your computer and use it in GitHub Desktop.
Bash - looping over .ssh/config and execute traceroute which stops after 25 seconds. Could be enhanced by highlighting traceroute results for certain greps.
#stop script by: CTRL C and also "pkill traceroute"
while IFS="" read -r p || [ -n "$p" ]
do
if [[ "$p" =~ ^Host.* ]];
then
printf '%s\n' "$p"
if [[ "$p" =~ ^Hostname.* ]];
then
traceroute "${p/Hostname /}" &
TASK_PID=$!
echo $TASK_PID
sleep 25
kill $TASK_PID
printf "\n\n\n\n"
fi
fi
done < .ssh/config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment