同一脚本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 ...
随机推荐
- 用户端访问centos7上面的tomcat,访问页面出现的非常的慢?
原因:因为客户端访问centos7上面的tomcat会先 建立session连接,这个连接会用到random的随机数,在linux系统中有一个熵池的概念(熵池是一个内核参数), 他要 用熵池里面的随机 ...
- 给echart初始化的dom节点绑定时间获取点击的值渲染省市区
this.drawMap().on('click', function (params) { var province = params.name; that.mapStatus = province ...
- classList用法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Java使用Redis--jedis
参考:菜鸟教程 http://www.runoob.com/redis/redis-java.html 1.Java 使用 Redis 开始在 Java 中使用 Redis 前, 我们需要确保已经安装 ...
- Vue打包npm run build 打包后空白怎么解决?
问题一:路径报错并且页面空白 解决:buld/index.js assetsPublicPath: '/'修改为 assetsPublicPath: './' 问题二:没报错页面空白 ro ...
- ASCII与HEX对照转换表
最近在研究ESC/POS 打印指令,时不时的就用到 ASCII和Hex的相互转换 ASCII HEX ASCII HEX ASCII HEX ASCII HEX NUL 00 DEL 10 Space ...
- JAVA写接口傻瓜(%)教程(五)
今天主要说一下在URL 中使用?传值的问题.在显式的使用get方法获取特点数据时,一般会通过?传递参数值,sevlert根据参数在数据库中对应的查找内容.所以,SQL语句需要拼接,要加上后面的参数.参 ...
- day2作业
购物车(两个程序)用户入口1商品信息存在文件里2已购商品,余额记录商家入口2可以添加商品,修改商品价格
- 2015-112 ado.net2
CRUD:create read update delete 七. 数据绑定数据列的转换 在gridview中添加<OnRowDataBound="GridView1_RowDataB ...
- nextcloud大文件无法上传
I think that if u got a small /tmp like i had u cant upload big file…My /tmp = 462M so i can upload ...