Expect Script sending password with $ and symbols

All,
I am trying to use expect to send SFTP password because I am unable to share a key with the vendor.

They gave me a password that uses some symbols in it like $ and !

When i try to use the send command in expect it thinks the $ is a variable.

Is there anyway to have it send the actual string and not try to act like a variable?

Try escaping the $ like \$

I tried that earlier and it didn't work, but then I noticed that my expect for the password prompt was different.

I fixed that and also added the escape character and it worked!

Thanks Corona.

So, on expect, you have to put the exact line that it will be expecting right? Also, anyway to get the exit status of an sftp command within expect?

Also how can I get the next command to wait util the previous command finishes?

---------- Post updated at 11:26 AM ---------- Previous update was at 10:55 AM ----------

Ok. I have one more issue. My files are not completing before it exits. It just cuts off while in the middle of transferring

How can I get my expect script to wait till the mput command is finished?

expect <<EOF | tee -a $LOGFILE
spawn sftp -o Port=$PORT $DESTUSER@$DESTSERV
expect " password:"
send "$PASSWORD\n"
sleep 2
expect "sftp>"
send "cd $DESTLOC\n"
expect "sftp>"
send "lcd $ORIGLOC\n"
expect "sftp>"
send "mput *\n"
expect "sftp>"
send "exit\n"

---------- Post updated at 12:47 PM ---------- Previous update was at 11:26 AM ----------

Ok, i got that piece resolved I just had to set the timeout.

Is there anyway to tell expect to exit if it doesn't get what it expects?