Telnet - waitfor examples

Hi guys,

Could you please send me a few examples of how to use the waitfor
function once you establish a telnet connection?
My problem is that, I’m telnetting to a device, I’m changing the
hostname, and then I’m rebooting it. When it comes back up, I want to
use waitfor to verify that the hostname was succesfully changed.

Thanks,
nate