fix to cehck SUCEEDED OR FAILED at the end of code, also store ssh conne...

...ction