syntax error near unexpected token `newline'脚本无法执行
来源:互联网 发布:微信网站怎么制作 知乎 编辑:程序博客网 时间:2024/05/22 14:11
问题描述
执行run.sh脚本是报错,报错信息如下:
/data/app/information-provider: No such file or directory: command not found./run.sh: line 4: syntax error near unexpected token `newline''/run.sh: line 4: `case "$1" in
问题分析
查找脚本,脚本并没有问题, 于是怀疑是否文件格式不正确。
通过下面命令查看文件,
cat -A run.sh
发现run.sh中,换行是以^M$结尾
server="$( dirname "${BASH_SOURCE[0]}" )" && pwd ^M$cd $server^M$^M$case "$1" in ^M$ ^M$ ...
解决办法
执行下面语句将run.sh转换为linux环境下换行符$
dos2unix run.sh
通过cat -A run.sh查看转换文件为:
server="$( dirname "${BASH_SOURCE[0]}" )" && pwd $cd $server$$case "$1" in $ $
0 0
- syntax error near unexpected token `newline'脚本无法执行
- repo error : line 1:syntax error near unexpected token 'newline'
- 脚本报syntax error near unexpected token `(',
- syntax error near unexpected token `
- syntax error near unexpected token `('
- “syntax error near unexpected token `”
- syntax error near unexpected token `
- 解决执行脚本报syntax error: unexpected end of file或syntax error near unexpected token `fi'错误的问题
- linux执行SHELL脚本报错“syntax error near unexpected token `in”解决
- linux执行SHELL脚本报错“syntax error near unexpected token `in”解决
- linux执行SHELL脚本报错“syntax error near unexpected token `in”解决
- rsync 脚本报错 “syntax error near unexpected token `(”
- shell 脚本报错^M: syntax error near unexpected token
- linux shell脚本syntax error near unexpected token `then'
- 脚本报错:syntax error near unexpected token
- Android-~/bin/repo: line 1: syntax error near unexpected token `newline
- bash: syntax error near unexpected token `newline'(关键词:flask/bug)
- libtool: syntax error near unexpected token `]*'
- linux学习笔记--route命令
- wordpress数据字典
- MyBatis 逆向工程生产源码(po、mapper)
- 2016总结-学习-健康-坚持
- Android-IPC之二
- syntax error near unexpected token `newline'脚本无法执行
- Andorid完美退出应用
- 密码日记
- ORACLE下载当中的gateways,companion,clusterware都是什么用途?
- 1104. Sum of Number Segments (20)解题报告
- 利用Python替换文件中的字符串
- 自动化一步一步来之ant+ivy+jacoco+testNG+tomcat搭建
- Android 联系人模糊查询
- 图——Floyd算法