title: How to put if statement inside a lftp block
body: <p>I am writing a bash script to download files from ftp server using lftp. I wanted to delete the files based on the second input argument. </p>
  
  <pre><code>#!/bin/bash
  
  cd $1
  
  lftp -u found,e48RgK7s sftp://ftp.xxx.org &lt;&lt; EOF
  set xfer:clobber on
  mget *.xml
  if [ $2 = "prod"]; then
    echo "Production mode. Deleting files"
    mrm *.xml
  else
    echo "Non-prod mode. Keeping files"
  fi
  EOF
  </code></pre>
  
  <p>However, if statement is not allowed in the lftp block before EOF. </p>
  
  <pre><code>Unknown command `if'.
  Unknown command `then'.
  Usage: rm [-r] [-f] files...
  Unknown command `else'.
  </code></pre>
  
  <p>How do I embed if statement in such block?</p>