title: How to wait for system command to end
body: <p>I'm converting an XLS 2 CSV file with a system command in Ruby.  </p>
  
  <p>After the conversion I'm processing the CSV files, but the conversion is still running when the program wants to process the files, so at that time they are non-existent.</p>
  
  <p>Can someone tell me if it's possible to let Ruby wait the right amount of time for the system command to finish?  </p>
  
  <p>Right now I'm using:</p>
  
  <pre><code>sleep 20
  </code></pre>
  
  <p>but if it will take longer once, it isn't right of course.</p>
  
  <p>What I do specifically is this:</p>
  
  <pre><code>#Call on the program to convert xls
  command = "C:/Development/Tools/xls2csv/xls2csv.exe C:/TDLINK/file1.xls"
  system(command)
  do_stuff
  
  def do_stuff
  #This is where i use file1.csv, however, it isn't here yet
  end
  </code></pre>