title: Automate pressing enter key inside of bash script
body: <p>I have a Bash script where I try to wget a repo for which I have to press enter for a very long Eula text, literally I have to manually press enter key 20+ times and then type yes. Can someone please help me to automate pressing enter key and at the end enter yes in bash script.</p>
  
  <pre><code>yes "" | command
  </code></pre>
  
  <p>and</p>
  
  <pre><code>echo -ne '\n' | &lt;command&gt; 
  </code></pre>
  
  <p>doesn't work for me, I still have to manually press enter key.</p>
  
  <p>Here is the code, so when it runs wget, I need to keep pressing enter till it ask if you want to accept the license and there I enter "yes".</p>
  
  <pre><code>#!/bin/bash
  
  pid=$(ps aux | grep xxx-server |grep -v grep | awk '{print $2}')
  if [ -n "$pid" ]; then
      kill $pid
      echo -e  "\n$pid killed -Success"
  fi
  # Check if the package already installed then remove it
  
  if [ `dpkg -l | grep xxx-server  | wc -l` -gt "0"  ]
  then
      apt-get -y remove  xxx-server
  fi
  # wget the repo using silent install
  if [ "apt-cache search xxx-server" ];then
  #if [ $? != 0 ] ; then
          echo -e  "\nremoving repo ...."
          #aptitude install $i -y &gt; /dev/null
           apt-get purge xxx-server-repo-* -y  &gt; /dev/null
           echo -e  "\nInstalling Reop .........."
  
   yes "" | wget -q -O - http://xxx-server.com/ | sh
  
  fi
  </code></pre>