Trouble passing commands with expect

Hello All,

I hope someone could help me with this.

I'm creating a shell script to run a process. The trouble is, part of the process has to be ran as a different user. I can 'su' to the user ok, but I'm having trouble passing a 'cd' command as well as some variables I set earlier in the script.

Here's what I have:

When I execute I get this error:

$ $ cp: SOMETHING.log: A file or directory in the path name does not exist.
$ invalid command name "cp"
while executing

Seems the 'cd' works, but it places a '$' in the beginning of the line, which is throwing off the rest of the script. My questions are, how can I 'cd' properly using expect and is it possible to pass a variable this way?

Try to replace cd with \cd or chdir
And then, shouldn't there be another expect for each $ prompt?