同一脚本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 ...
随机推荐
- php 更改PHP临时文件的目录
$_FILES['upfile']['tmp_name'] 获取php.ini 存放路径 php.ini 里 upload_tmp_dir 设置一个全新的目录
- loadrunner中使用web_custom_request函数调用webservice接口
1.使用的接口地址: http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?op=getWeatherbyCityName 以SOAP ...
- JS-getHours()方法
var time=new Date().getHours(); 获取当前系统时间的小时值,eg:若当前系统时间为2019.4.25 10:52 则返回10
- 1.1 Django起步
1.1 Django起步 1.1.1. Django简介 Django开发框架(简称Django)诞生的时间是2003年的金秋时节,美国有两位程序员Adrian Holovaty和Simon ...
- NetSec2019 20165327 Exp4 恶意代码分析
NetSec2019 20165327 Exp4 恶意代码分析 一.实践目标 1.监控你自己系统的运行状态,看有没有可疑的程序在运行. 2.分析一个恶意软件,就分析Exp2或Exp3中生成后门软件:分 ...
- 创建springboot项目
springboot 就是为简化spring的创建 配置 部署 运行 而创建的. springboot 直接引入依赖jar包 就行了,无须配置xml 一 创建springboot 1.创建一个mave ...
- 【转】Appium如何定位安卓APP元素
转载原文:https://www.jianshu.com/p/efe9dcf8bbaf 一.定位工具 在安装appium环境的时候我们已经安装了SDK,里面就自带有元素定位的工具,位置在.../sdk ...
- 论文笔记(Filter Pruning via Geometric Median for Deep Convolutional Neural Networks Acceleration)
这是CVPR 2019的一篇oral. 预备知识点:Geometric median 几何中位数 \begin{equation}\underset{y \in \mathbb{R}^{n}}{\ar ...
- linux 每天一点点 【ubuntu16.04 】
1.查看防火墙状态 sudo ufw status [非root用户需要sudo] inactive状态是防火墙关闭状态 active是开启状态 2.查看CentOS版本信息 cat /etc ...
- MariaDB主从复制,redis发布订阅,持久化,以及主从同步
一. MariaDB主从复制 mysql基本操作 1 连接数据库 mysql -u root -p -h 127.0.0.1 mysql -u root -p -h 192.168.12.60 2 ...