title: Bash script to spawn and execute commands
body: <p>I am trying to create a bash script to ssh into a session and run a command then exit out of the session. currently this is what i have so far:</p>
  
  <pre><code>#!/usr/bin/expect -f
  
  spawn ssh root@sc
  expect "assword:"
  send "password\r"
  expect "#"
  send "cd /data2/someDirectory\r"------&gt; don't see this command being executed
  </code></pre>
  
  <p>and the output</p>
  
  <pre><code>[user@San ddb]$ test1
  spawn ssh root@sc
  root@sc's password:
  SC02 RH 7.3 (0000009B 02.11.0.1)
  [root@sc /]# [user@san1 ddb]$
  [user@san1 ddb]$
  </code></pre>
  
  <p>So my question is why isn't the directory being set to myDirectory and it just exits out of the session?</p>