Bash脚本行106:语法错误:意外的文件结束

时间:2017-06-12 17:34:05

标签: linux bash shell

这是我的第一个剧本,所以请保持温柔。我知道文件语法错误的意外结束通常是if if without a fi,因为没有完成或缺少引号等。我找不到上面的任何内容。我有一种感觉,它可能是我试图用echo写文件httpd.conf的代码的一部分,但我不确定。任何人都可以发现错误,提示和建议吗?谢谢。

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 && 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"' > /home/jared/apache2/conf/httpd.conf
    fi

chmod 644 /home/jared/apache2/conf/httpd.conf

echo $INSTALL_DIRECTORY      

1 个答案:

答案 0 :(得分:0)

var getResourceHandler = dojo.xhrPost( {
  url: feedUrl,
  content: {
      nlsStringKey: key
  },
  sync: true,
  handleAs: "json",
  preventCache: false,
  load: function(data){
      console.debug(data);
      resourceList = data;
  },
  error: function(error){
      console.debug("getNlsStringFromFeed ERROR");
      console.debug(error);
  }

应该是

var getResourceHandler = $.ajax({
   method: "POST",
   url: feedUrl,
   data: { nlsStringKey : key },
   dataType:"json",
   cache:true
});

getResourceHandler.done(function(data){
    console.debug(data);
    resourceList = data;
});

getResourceHandler.fail(function(error){
    console.debug("getNlsStringFromFeed ERROR");
    console.debug(error);
});