Well, firstly I must say that putting passwords in an expect script is almost always a terrible idea, both from a security and maintainability standpoint.
Here's an example expect script for using FTP:
link. The trick to detecting if it was a success or not is to know what the failure error message might look like, and have an expect clause for it. If you detect an error, call
Then, in your shell script, test $? as in the example with scp above.