full automation using expect, better error handling