title: How to write automated interactive shell script?
body: <p>I just want to write a shell script for automatic feeding the username and password prompts when running my commands,
  I tried this one but it did not work. Please help me for any way out.</p>
  
  <pre><code>#!/bin/bash
  #!/usr/bin/expect
  
  ls -ltr
  
  spawn sudo git pull
  
  expect "[sudo] password for sandeep:"
  
  send "sandeep123\n"
  
  expect "Username :"
  
  send "sandeep\n"
  
  expect "Password :"
  
  send "sandeep121\n"
  </code></pre>
  
  <p>I am getting following output :</p>
  
  <pre><code>sandeep@K2-Sandeep-08:~$ ./checkout.sh 
  total 64
  ./checkout.sh: line 8: spawn: command not found
  couldn't read file "Username:": no such file or directory
  ./checkout.sh: line 16: send: command not found
  couldn't read file "Password:": no such file or directory
  ./checkout.sh: line 20: send: command not found
  </code></pre>