同一脚本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日志
// 全局通用日志工具 function setlog($param = [],$result = [],$name='',$filename = 'm.log',$path = '/tmp/bear ...
- POJ 3616 奶牛挤奶
Milking Time 贝茜是一个勤劳的牛.事实上,她如此专注于最大化她的生产力,于是她决定安排下一个N(1≤N≤1,000,000)小时(方便地标记为0..N-1),以便她生产尽可能多的牛奶. ...
- selenium 模拟拖动滚动条下拉
senium做自动化测试的过程中,有的页面需要下拉滚动条才能全部加载完成,否则加载不出来就定位不到想要的元素. 参考链接:http://www.cnblogs.com/landhu/p/5761794 ...
- [Linux] 文档编辑搜索
vim filename press / type words which you want to search press Enter Q: How can I search only for wo ...
- .class 缓存
项目用的是Ant. 场景: Class A{ private static final String HHH="hello"; } Class B{ public void met ...
- 在vue中使用watch监听对象或数组
最近发现在vue中使用watch监听对象或者数组时,当数组或者对象只是单一的值改变时,并不会出发watch中的事件. 在找问题过程中,发现当数组使用push一类的方法时,会触发watch,如果只是单一 ...
- Lab 11-3
Analyze the malware found in Lab11-03.exe and Lab11-03.dll. Make sure that both files are in the sam ...
- Oracle中用户的创建和权限设置
权限: CREATE SESSION --允许用户登录数据库权限 CREATE TABLE --允许用户创建表权限 UNLIMITED TABLESPACE --允许用户在其他表空间随意建表 角色: ...
- Python学习周末练习1-用户登录
用户登录验证要求:1.用户登录输入账号.密码.4位随机大写字母验证码2.验证码错误重新输入3.有三次机会输入账号密码 count = 1 while count <= 3 : from rand ...
- Analysis servlet
@WebServlet("/cdiservlet") public class NewServlet extends HttpServlet { private Message m ...