title: Expect - send space bar until prompt
body: <p>I'm writing an expect script to login to a set of routers and run a command. The problem is different routers have different outputs for the command and so I need to send the space bar until the it displays the whole output. </p>
  
  <pre><code>#!/usr/bin/expect -f
  set f [open "test-ip"]
  set ip [split [read -nonewline $f] "\n"]
  close $f
  
  foreach host $ip {
          set timeout 2
          spawn ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -o "StrictHostKeyChecking no" -oHostKeyAlgorithms=+ssh-dss username@$ip
          sleep 2
          expect "word:"
          send "password\r"
          expect "#"
          send "sh media\r"
          expect {"#" {send "exit\r"}
                  "Control-c" { send -- { }; exp_continue}
          }
          expect "#" 
          send "exit\r"
          expect "&gt;"
          send "exit\r"
          close
  }
  </code></pre>
  
  <p>Right now it doesn't keep sending the spacebar until it sees a "#".</p>
  
  <p>Edit: Here's the debug</p>
  
  <pre><code>--More--, next page: Space, next line: Return key, quit: Control-c" (spawn_id exp4) match glob pattern ""#" {send -- "exit\r"}\n\t\t"Control-c" { send -- " "; exp_continue}\n        "? no
  expect: timed out
  </code></pre>