dos2unix xxx.sh
前几天写了一个Linux的自动化脚本,没有使用变量,就是一些Linux命令的集合
今天试着把一些相同的字段提出来用变量表示,然后在Linux里运行,就发现一直在报错:
: command not found24:
: command not found25:
: No such file or directoryas
: No such file or directoryoperties
: command not found29:
: No such file or directoryiguration.properties
: No such file or directoryiguration.properties
: No such file or directoryiguration.properties
: No such file or directoryiguration.properties
: No such file or directoryiguration.properties
: command not found35:
: command not found36:
我就很奇怪,怎么定义了变量就这么多问题,找了同事帮我看
她帮我调试了一下脚本,
发现了问题,原来我这个脚本是在windows下编辑过,然后再cp到Linux系统上,之间存在一些编码不兼容的问题,导致Linux不认识这个脚本
dos2unix xxx.sh
使用了上面的那个命令,让脚本里的编码格式转化成Linux认识的,这些就没有问题啦。。
dos2unix xxx.sh的更多相关文章
- -bash: ./xxx.sh: /bin/bash^M: bad interpreter: No such file or directory
问题的原因是在windows下编辑然后上传到linux系统里执行的..sh文件的格式为dos格式.而linux只能执行格式为unix格式的脚本. 不要使用记事本编辑,使用代码编辑器可以正常执行
- .xxx.sh脚本无法启动,原来都是特殊字符搞的鬼?
今天遇到个趣的问题,linux上springboot启动,连接达梦数据库报错. 解决思路: 1)是不是数据库本身有问题,客户端登录没问题. 2)排查是不是war包问题,本地连接数据库,没问题. 3)是 ...
- 执行xxx.sh脚本的两种方式
因公司测试环境的登录模式有2种,大佬们直接写了个脚本完成一键切换,看了其中的脚本文件,其中出现了send "sh out.sh\r":一直疑惑这里的sh out.sh的意思...查 ...
- 面试:如何把xxx.sh使用/etc/init.d/xxx.sh start启动,并且可以用chkconfig配置开机自启动
chkconfig原理: 1.脚本放到/etc/init.d下面,并且可执行(/etc/init.d/sshd) 需要被chkconfig管理,需要添加进去chkconfig --add sshd ...
- cygwin的sh: line 15: $'\r': command not found错误
安装dos2unix工具,转换一下sh文件即可 apt-cyg install dos2unix dos2unix xxx.sh
- 报错解决——linux下执行sh出现异常"syntax error: unexpected end of file"
有时我们在linux下执行一个sh文件,会报错“SYNTAX ERROR:UNEXPECTED END OF FILE”,这个现象主要是工作的系统环境改变造成的. 若最初脚本中是在windows下,使 ...
- docker 会这些也够
$ sudo systemctl start docker $ sudo systemctl stop docker $ sudo systemctl restart docker If you wa ...
- shell脚本遇到问题"$'\r': command not found"
shell脚本写得一切正常,但是一执行就报错: line: XXX "$'\r': command not found" 问题原因:文件格式问题(虽然在window和linux上选 ...
- zabbix自定义监控nginx
nginx配置ngx_status 1.编译安装时带上--with-http_stub_status_module参数 2.vi nginx.conf location ~* ^/ngx_status ...
随机推荐
- POJ 1523 SPF 割点 Tarjan
SPF Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9317 Accepted: 4218 Description C ...
- JAVA NIO 之 Selector 组件
NIO 重要功能就是实现多路复用.Selector是SelectableChannel对象的多路复用器.一些基础知识: 选择器(Selector):选择器类管理着一个被注册的通道集合的信息和它们的就绪 ...
- Windows 10+Ubuntu 16.04在MBR分区上安装双系统(转)
以下内容转自这篇博客: http://www.cnblogs.com/Duane/p/5424218.html http://www.cnblogs.com/Duane/p/6776302.html( ...
- AWR and ADDM
The Automatic Workload Repository Oracle collect a vast amount of statistics regarding the performan ...
- python requests使用
参考:http://cn.python-requests.org/zh_CN/latest/ 1.使用requests发送请求: >>> r = requests.get('http ...
- ROBODK仿真如何设置运动速度
设置工具-选项-运动,把仿真时间设置成跟正常一样 然后双击机器人,设置参数(可以设置movej和movel的速度,加速度)
- 小米2S 小米手机如何手动升级到开发版
1 从官网下载系统的更新包,比如对于小米2S,从下面的网址下载. http://www.miui.com/download-2.html 2 下载完成之后,放到手机的任意文件夹下,比如下面的S ...
- 移动匿名支付购物方案 A Lightweight Anonymous Mobile Shopping Scheme Based on DAA for Trusted Mobile Platform
- shell学习三十七天----引用
引用 案例,假设我想输出一个星号(*),使用echo怎样做? echo * 这是肯定不行的,须要将*转移,即:echo \* 这样就引出了引用的概念.所为引用,是用来防止shell将某些你想要的东西解 ...
- 由文字生成path后制作写字的动画
在看以下这个开源组件的时候,发现一个非常棒的方法,能够将文字生成path,这样就能够作出用笔写字的效果了. https://github.com/MP0w/MPParallaxCollection 关 ...