title: Bash - Start Script running again?
body: <p>I'm trying to learn some scripting.
  I have a scenario where I have lost my truecrypt password. I run the script below.</p>
  
  <pre><code>#!/bin/sh
  DIRECTORY=/media/truecrypt1
  for i in 1 2 password
  do
     clear
     echo "Trying $i as a password"
     truecrypt -k "" --protect-hidden=no ITSTUDY $DIRECTORY -p $i
     if [[ -d "${DIRECTORY}" &amp;&amp; ! -L "${DIRECTORY}" ]] ; then
         echo "It Worked!"
     fi
  done
  </code></pre>
  
  <p>However if the password is wrong I get </p>
  
  <pre><code>Trying 1 as a password
  Incorrect password or not a TrueCrypt volume.
  Enter password for /mnt/ITSTUDY:
  </code></pre>
  
  <p>The only way to get the script to start running again I have to ctrl+c. If I push ctrl+c after each failure eventually the script gets to the correct password. However if I have 1000 possible passwords that is not an option.</p>
  
  <p>How do I get the script to look for the output </p>
  
  <p><strong>Incorrect password or not a TrueCrypt volume.</strong></p>
  
  <p>then send a ctrl+c? or quit? Everything I've tried so far doesn't proceed below the truecrypt -k line until I do the ctrl+c.</p>