title: Bash script line 106: syntax error: unexpected end of file
body: <p>This is my first script so please be gentle. I know the unexpected end of file syntax error is usually an if without a fi, for without a done or missing quotes etc. I cannot find any of the above. I have a feeling it might be the part of the code where I am trying to write to file httpd.conf with echo, but I am not sure. Can anybody spot whats wrong, tips, suggestions? Thank you.   </p>
  
  <pre><code>enter code here#!/bin/bash
  
  
  INSTALL_DIRECTORY=/home/jared
  export INSTALL_DIRECTORY
  cd ; pwd
  
  #If statement to create directories if they are not made
      if test -d apache2 &amp;&amp; if test -d www2
          then
              echo "Directories already exist" 
      else
          mkdir apache2 www2
      fi
  
  cd apache2
  
  #If statement to create files if they are not made
      if test -d bin
          then
              echo "Directory already exists"
      else
          mkdir bin
      fi
  
      if test -d conf
          then
              echo "Directory already exists"
      else
          mkdir conf
      fi
  
      if test -d lib
          then
              echo "Directory already exists"
      else
          mkdir lib
      fi
  
      cd /home/jared/www2
  
      if test -d html
          then
              echo "Directory already exists"
      else
           mkdir html
      fi
  
      if test -d cgi-bin
          then
              echo "Directory already exists"
      else
          mkdir cgi-bin
      fi
  
      if test -d ftp
          then
              echo "Directory already exists"
      else
          mkdir ftp
      fi
  
  
  #Changing the permissions
  chmod -R 755 apache2 ; chmod -R 750 www2
  cd www2 ; chmod 722 ftp ; cd ../apache2/bin
  
  #Creating the files
  touch httpd ; chmod 755 httpd ; cd /home/jared/www2/html
  touch index.html ; chmod 644 index.html ; cd ../cgi-bin
  touch process.pl ; chmod 711 process.pl
  
  cd ; cd /home/jared/apache2/conf
  
  #Creating the httpd.conf file if it does not already exist
  #and adding details
  
      if test -s httpd.conf
          then
              echo "File already exists"
      else
          echo '#
      #This is the main Apache HTTP server configuration file.It contains
      #configuration directives that give the server its instructions.
      #Do not add a slash at the end of the directory path.
      #
      ServerRoot "/home/jared/apache1"
      #
      #DocumentRoot: The directory out of which you will server your documents.
      #
      DocumentRoot "/home/jared/www1"' &gt; /home/jared/apache2/conf/httpd.conf
      fi
  
  chmod 644 /home/jared/apache2/conf/httpd.conf
  
  echo $INSTALL_DIRECTORY      
  </code></pre>