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. ACdream 1726 A Math game

    深搜.不过有一个强大的剪枝.就是假设之后的全部用上都不能达到H,则return. if (A[n]-A[x-1]+summ< H) return; //A[n]表示前nx项和 #include& ...

  2. Monkey总结

    Monkey是一个快速检查内存泄露的好工具,可以初步发现较明显的内存泄露问题. 什么是内存泄露?是指不在使用的对象持续占有内存,造成内存空间的浪费. 检查内存泄露的基本操作步骤: 1.运行Monkey ...

  3. html5--画布

    简介 canvas是HTML5中的新元素,你可以使用javascript用它来绘制图形.图标.以及其它任何视觉性图像.它也可用于创建图片特效和动画.canvas 元素本身是没有绘图能力的.所有的绘制工 ...

  4. 《JS权威指南学习总结--6.8对象的三个属性》

    内容要点: 每一个对象都有与之相关的原型(prototype).类(class)和可扩展性 一.原型属性 1.对象的原型属性是用来继承属性的,这个属性是如此重要,以至于我们经常把 "0的原型 ...

  5. strpos 返回0时 ,比较false 不能加单引号

    $a =  'a.approve'; $num = strpos($a,'a.admin'); if(strpos($a,'a.approve') !== 'false'){ //不能加单引号.变字符 ...

  6. GitHub赠送DigitalOcean优惠码100美元

    著名的项目托管网站GitHub本周联合DigitalOcean VPS和NameCheap送给学生福利了!十余种产品免费拿!包括免费赠送digitalocean优惠码价值100美元!以及nameche ...

  7. SqlServer 汉字转换拼音首字母函数

    CREATE function [dbo].[Func_GetPY](@str nvarchar(4000))returns nvarchar(4000)asbegin set @str=RTRIM( ...

  8. Android Lights

    Android Lights 很多Android手机上都配有LED灯,手机在充电.新来短信等时候都会有相应的指示灯提示. Android系统之中,一共定义了8个逻辑灯,包含:背光,键盘灯,按键灯,充电 ...

  9. Git一些其它的功能

    Git 开始之前我们配置过user.name和user.email.其实还有很多其他的配置项 例如:让Git显示颜色,会让命令输出来更醒目: $ git config --global color.u ...

  10. HDtune(硬盘检测) V5.5 中文绿色版

    软件名称:HDtune(硬盘检测) V5.5 中文绿色版软件语言: 简体中文授权方式: 免费软件运行环境: Win 32位/64位软件大小: 565KB 图片预览: 软件简介:HD Tune Pro一 ...