Shell script fails: Syntax error: “(” unexpected

google 一下。

http://unix.stackexchange.com/questions/45781/shell-script-fails-syntax-error-unexpected

The script does not begin with a shebang line, so the kernel executes it with /bin/sh. On Ubuntu, /bin/sh is dash, a shell designed for fast startup and execution with only standard features. When dash reaches line 68, it sees a syntax error: that parenthesis doesn't mean anything to it in context.

Since dash (like all other shells) is an interpreter, it won't complain until the execution reaches the problematic line. So even if the script successfully started at some point in your testing, it would have aborted once line 68 was reached.

The shebang line must be the very first thing in the file. Since you use bash features, the first line of the file must be #!/bin/bash or #!/usr/bin/env bash.

就是把第一行改为 #!/bin/bash 或者  #!/usr/bin/env bash  

Shell script fails: Syntax error: “(” unexpected的更多相关文章

  1. Shell脚本:“syntax error:unexpected end of file”

    这种错误只能说是坑,如果没有见到过,很可能就要摔里头.解决问题是重要的,但弄明白问题的来源,往往更为重要. 所以要先扯一下,换行和回车的历史遗留问题. 在计算机出现之前,有个玩意叫电传打字机.每秒钟可 ...

  2. SHELL syntax error:unexpected end of file 提示错误

    SHELL syntax error:unexpected end of file 提示错误 if [ -n "$1" ] then " else " fi e ...

  3. shell 报错:syntax error: unexpected end of file

    有时执行脚本时会报错: [root@host1 shell]# sh -x test.sh + $'\r' : command not found test.: syntax error: unexp ...

  4. 不同系统执行相同shell脚本,出现Syntax error: "(" unexpected错误解决

    例如shell脚本在centos系统中能正常执行,而在ubuntu系统中执行会出现类似Syntax error: "(" unexpected的错误,一般这种是因为sh与bash有 ...

  5. 【shell】真正解决syntax error:unexpected end of file?

    今天写了个较长的shell脚本,结构嵌套比较多,最后运行时,出现了syntax error: unexpected end of file的错误. 这个之前碰到过,经常在win系统转移脚本文件到uni ...

  6. shell:syntax error:unexpected end of file/Starting proxy www-balancer: cannot bind socket--转载

    src:http://www.2cto.com/os/201308/238962.html   执行某bash脚本是发生: syntax error: unexpected end of file 主 ...

  7. 执行shell脚本报错:syntax error near unexpected token `或syntax error: unexpected end of file

    引起此问题最可能的原因是: 在windows下编写的文件上传到linux执行. 我是在notepad++上编写的代码,之后上传到linux执行,报此错误.仔细检查,语法方面没有错误.上网查了一下,发现 ...

  8. 执行shell脚本遇到错误syntax error: unexpected "then" (expecting "}")

    今天执行脚本的时候遇到错误,如下图: root@ApFree:/usr/sbin# ./conntrack_num_graph.sh ./conntrack_num_graph.sh: line : ...

  9. 报错解决——linux下执行sh出现异常"syntax error: unexpected end of file"

    有时我们在linux下执行一个sh文件,会报错“SYNTAX ERROR:UNEXPECTED END OF FILE”,这个现象主要是工作的系统环境改变造成的. 若最初脚本中是在windows下,使 ...

随机推荐

  1. Java AOP - Aspectj

    1. 序 Aspect Oriented Programming (AOP)是近来一个比较热门的话题. AspectJ是AOP的Java语言的实现,获得了Java程序员的广泛关注. 关于AspectJ ...

  2. django+nginx+uwsgi 部署配置

    django官方文档在这 https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/uwsgi/ 第一步:先收集静态文件 之前要先设置 S ...

  3. php 类型

    var_dump 打印出类型和值     整型inter用  decimal 表示为 decimal : [1-9][0-9]* | 0   (int) ( (0.1+0.7) * 10 ); 强制类 ...

  4. CSS3秘笈复习:第十一章

    1.text-align与vertical-align: text-align控制水平方向的定位,关键字是left.right.center和justify. vertical-align控制垂直方向 ...

  5. Jquery获得 selection的text 和 option值

    Jquery获得 selection的text 和 option值 <select id="accountStatus" editable="false" ...

  6. Infix to postfix without '(' and ')'

    #include<iostream> #include<stack> #include<string> #include<deque> using na ...

  7. JVM基础(5)-垃圾回收机制

    一.对象引用的类型 Java 中的垃圾回收一般是在 Java 堆中进行,因为堆中几乎存放了 Java 中所有的对象实例.谈到 Java 堆中的垃圾回收,自然要谈到引用.在 JDK1.2 之前,Java ...

  8. jsonp原来是这么回事,豁然开朗

    什么是JSONP 先说说JSONP是怎么产生的: 其实网上关于JSONP的讲解有很多,但却千篇一律,而且云里雾里,对于很多刚接触的人来讲理解起来有些困难,小可不才,试着用自己的方式来阐释一下这个问题, ...

  9. IE6下的bug

    一.IE6双倍边距bug 当页面上的元素使用float浮动时,不管是向左还是向右浮动:只要该元素带有margin像素都会使该值乘以2,例如“margin-left:10px” 在IE6中,该值就会被解 ...

  10. Arch最小化安装LXDE桌面环境

    安装最小化的LXDE桌面环境: pacman -S lxde-common 安装LXDE Session: pacman -S lxsession 不安装这个没法登录进桌面环境 安装LXDE面板: p ...