fix some bugs about using Expect. For a fault free run, be sure Expect ends the process after ssh exits.