同一脚本sh 脚本名 报Syntax error: "(" unexpected而./脚本名不报错,求解!!
同一脚本sh 脚本名 执行时报Syntax error: "(" unexpected;而./脚本名执行不报错,为什么呢
脚本内容如下:
function usage(){
echo "usage:$0 url"
exit
} function check_url(){
wget --spider -q -o /dev/null --tries= -T $
if [ $? -eq ]
then
echo "$1 is ok"
else
echo "$1 is not ok "
fi
} function main(){
if [ $# -ne ]
then
usage
fi
check_url $
} main $*
yao@linux:~/shells$ ll 8_5_1.sh
-rw-r--r-- 1 yao yao 302 4月 27 11:13 8_5_1.sh
yao@linux:~/shells$ sh 8_5_1.sh
8_5_1.sh: 1: 8_5_1.sh: Syntax error: "(" unexpected
把脚本权限修改为755后,脚本正常执行
yao@linux:~/shells$ chmod 755 8_5_1.sh
yao@linux:~/shells$ ll 8_5_1.sh
-rwxr-xr-x 1 yao yao 302 4月 27 11:13 8_5_1.sh*
yao@linux:~/shells$ ./8_5_1.sh
usage:./8_5_1.sh url
同一脚本sh 脚本名 报Syntax error: "(" unexpected而./脚本名不报错,求解!!的更多相关文章
- win-Linux文件脚本迁移过程中的问题 syntax error: unexpected end of file
问题: 在win下写好的shell脚本,放到Linux上测试sh -n报错如下 ORA_check.sh: line 251: syntax error: unexpected end of fil ...
- php报错syntax error, unexpected T_GOTO, expecting T_STRING,报错文件与行数指向以下代码,是什么原因?
本机php版本是5.3.8,Apache/2.2.21public function goto($url, $msg=NULL) {if ($msg) {$this->jsAlert($msg) ...
- 报错解决——linux下执行sh出现异常"syntax error: unexpected end of file"
有时我们在linux下执行一个sh文件,会报错“SYNTAX ERROR:UNEXPECTED END OF FILE”,这个现象主要是工作的系统环境改变造成的. 若最初脚本中是在windows下,使 ...
- Windows登录服务器CLI运行脚本出现 syntax error: unexpected end of file 错误的解决
0.前言 通常我们在编辑 Linux 服务器上的文件时,直接在 Linux 环境比较麻烦(当然熟练使用 VIM 的程序员除外哈哈),有时我们会使用 Windows 将文件编辑好再上传到服务器端,我用的 ...
- 执行shell脚本遇到错误syntax error: unexpected "then" (expecting "}")
今天执行脚本的时候遇到错误,如下图: root@ApFree:/usr/sbin# ./conntrack_num_graph.sh ./conntrack_num_graph.sh: line : ...
- 不同系统执行相同shell脚本,出现Syntax error: "(" unexpected错误解决
例如shell脚本在centos系统中能正常执行,而在ubuntu系统中执行会出现类似Syntax error: "(" unexpected的错误,一般这种是因为sh与bash有 ...
- linux 报错 bash ‘/bin/sh: Syntax error: “(” unexpected
今天用make 编译 蹦到 bash ‘/bin/sh: Syntax error: “(” unexpected 和 /bin/sh: [[: not found 这种莫名奇妙的错误 原因是是lin ...
- 【玩转Ubuntu】08. Linux报错:Syntax error: "(" unexpected解决办法
问题: 在MAC上写了一段shell脚本,放到Ubuntu上运行总是报下面这个错误,单步调试都是对的,就是直接运行会报错. bixiaopeng@ubuntu:~/package$ sh packag ...
- shell 报错:syntax error: unexpected end of file
有时执行脚本时会报错: [root@host1 shell]# sh -x test.sh + $'\r' : command not found test.: syntax error: unexp ...
随机推荐
- 蚂蚁风险大脑亮相ATEC城市峰会:为数字经济时代做好“安全守护”
2019年1月4日,以“数字金融新原力(The New Force of Digital Finance)”为主题的蚂蚁金服ATEC城市峰会在上海隆重举行.大会聚焦金融数字化转型,分享新技术的发展趋势 ...
- Qt551.OpenGL.ZC简单例子
1.主要 模仿代码:OpenGL的教程 第3课 "tutorial03_matrices"的代码(E:\OpenGL_something\ogl-master) 2.参考代码:Qt ...
- gcc使用及动静态库制作
一. GCC的使用 1. GCC的编译过程 (1)预处理(cpp)gcc -E(输出问价通常以 .i 结尾),将头文件展开,宏替换等操作: (2)编译器(gcc)gcc -S(输出问价以 .s 结尾) ...
- QTL定位相关
1.原理 https://www.sohu.com/a/211301179_278730 较为详细
- java.nio.file.NoSuchFileException
springboot +es es 2.1.0 参考这个 https://www.cnblogs.com/yueshutong/p/9381543.html cluster-nodes :改成127. ...
- unity项目build成webgl时选择生成目录(解决方法)
在unity里点击File>>Build Settings...>>勾选你要生成的Scenes>>选择webgl>>后面Development Buil ...
- hdoj4859海岸线
1.地图周围再加一圈海 2.周长最多为sum=n*(m+1)+m*(n+1).如果有邻接相同,要减1.最小割使相同最少.结果为sum-最小割 3.但是有E海滩,两边都能选.让E到S,T都连一个很大的数 ...
- 微信小程序的MVVM思想
本文参照:[微信小程序开发]秒懂,架构及框架 同时多看:https://blog.csdn.net/qq_26585943/article/details/54378684 微信小程序开发,主要分清楚 ...
- LNMP的搭建
一.下载安装MySQL 1.1:下载地址:https://dev.mysql.com/downloads/mysql/ 1.2:安装后 1.2.1:解压:tar -xf mysql-8.0.15-li ...
- git不提交某个文件
在版本库中的文件,即使维护在.gitignore也不管用了.要先移除. 比如Constants.java,进入到这个文件目录下: 第一步:git rm -r -n —cached Constants. ...