title: unable to get the $expect_out(buffer) and $expect_out(0,string) values in shell with expect
body: <p>If i code expect into shell script, I am unable to get the values of $expect_out(buffer) and $expect_out(0,string).</p>
  
  <p>Below are the sample codes that i coded.</p>
  
  <pre><code> [Linux Dev:upncommn ~]$ cat expshl.sh
   #!/bin/bash
   expect &lt;&lt; EOF
   spawn  "/home/upncommn/expectecho.sh"
   expect {
   "hi"  { send_user "You said_hi $expect_out(buffer)\n";
           send_user "Sting $expect_out(0,string)\n"
                   exit 1
          }
   "*bd*" { send_user "You said $expect_out(buffer)\n"
            send_user "Sting $expect_out(0,string)\n"
                    exit 2
              }
   timeout { send_user "timeout\n"; exit 3 }
   }
   EOF
  
  
   [Linux Dev:upncommn ~]$ cat expectecho.sh
   echo "hello"
   echo "abduls"
   echo "theos"
   echo "this is abdul"
  
  
   [Linux Dev:upncommn ~]$ ./expshl.sh
   spawn /home/upncommn/expectecho.sh
   hello
   abduls
   theos
   You said (buffer)
   Sting (0,string)
  
  
   [Linux Dev:upncommn ~]$ echo $?
   2
  </code></pre>
  
  <p>Please help me to get the $expect_out(buffer) and $expect_out(0,string).</p>