前几天写了一个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的更多相关文章

  1. -bash: ./xxx.sh: /bin/bash^M: bad interpreter: No such file or directory

    问题的原因是在windows下编辑然后上传到linux系统里执行的..sh文件的格式为dos格式.而linux只能执行格式为unix格式的脚本. 不要使用记事本编辑,使用代码编辑器可以正常执行

  2. .xxx.sh脚本无法启动,原来都是特殊字符搞的鬼?

    今天遇到个趣的问题,linux上springboot启动,连接达梦数据库报错. 解决思路: 1)是不是数据库本身有问题,客户端登录没问题. 2)排查是不是war包问题,本地连接数据库,没问题. 3)是 ...

  3. 执行xxx.sh脚本的两种方式

    因公司测试环境的登录模式有2种,大佬们直接写了个脚本完成一键切换,看了其中的脚本文件,其中出现了send "sh out.sh\r":一直疑惑这里的sh out.sh的意思...查 ...

  4. 面试:如何把xxx.sh使用/etc/init.d/xxx.sh start启动,并且可以用chkconfig配置开机自启动

    chkconfig原理: 1.脚本放到/etc/init.d下面,并且可执行(/etc/init.d/sshd) 需要被chkconfig管理,需要添加进去chkconfig  --add  sshd ...

  5. cygwin的sh: line 15: $'\r': command not found错误

    安装dos2unix工具,转换一下sh文件即可 apt-cyg install dos2unix dos2unix xxx.sh

  6. 报错解决——linux下执行sh出现异常"syntax error: unexpected end of file"

    有时我们在linux下执行一个sh文件,会报错“SYNTAX ERROR:UNEXPECTED END OF FILE”,这个现象主要是工作的系统环境改变造成的. 若最初脚本中是在windows下,使 ...

  7. docker 会这些也够

    $ sudo systemctl start docker $ sudo systemctl stop docker $ sudo systemctl restart docker If you wa ...

  8. shell脚本遇到问题"$'\r': command not found"

    shell脚本写得一切正常,但是一执行就报错: line: XXX "$'\r': command not found" 问题原因:文件格式问题(虽然在window和linux上选 ...

  9. zabbix自定义监控nginx

    nginx配置ngx_status 1.编译安装时带上--with-http_stub_status_module参数 2.vi nginx.conf location ~* ^/ngx_status ...

随机推荐

  1. 武大OJ 622. Symmetrical

    Description          Cyy likes something symmetrical, and Han Move likes something circular. Han Mov ...

  2. Android之设置拖拽监听

    以EditText为例: username.setOnDragListener(new OnDragListener() { @Overridepublic boolean onDrag(View v ...

  3. [Vue @Component] Write Vue Functional Components Inline

    Vue's functional components are small and flexible enough to be declared inside of .vue file next to ...

  4. 黑马程序猿——JAVA基础——IO流

    ----------android培训.java培训.java学习型技术博客.期待与您交流!------------  一. 一.IO流的三种分类方式 1.按流的方向分为:输入流和输出流 2.按流的数 ...

  5. OpenCV2马拉松第17圈——边缘检測(Canny边缘检測)

    计算机视觉讨论群162501053 转载请注明:http://blog.csdn.net/abcd1992719g 收入囊中 利用OpenCV Canny函数进行边缘检測 掌握Canny算法基本理论 ...

  6. Java 实现抽象工厂模式

    抽象工厂模式 里面有几个概念:抽象工厂.实体工厂.抽象产品.实体产品 抽象工厂:定义创建产品的抽象方法 实体工厂:详细的创建哪种产品 抽象产品:一个接口或基类 实体产品:实现详细功能,或派生 类图 ...

  7. LeetCode 893. Groups of Special-Equivalent Strings (特殊等价字符串组)

    题目标签:String 题目可以让在 偶数位置的 chars 互换, 也可以让 在 奇数位置的 chars 互换. 所以为了 return 正确的 group 数量,需要把 那些重复的 给排除掉. 可 ...

  8. 【bzoj1002】 [FJOI2007]轮状病毒DP

    递推+环状特殊处理+高精度   #include<algorithm> #include<iostream> #include<cstdlib> #include& ...

  9. js20170320

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  10. 第二章、Tiny4412 U-BOOT移植二 启动分析【转】

    本文转载自:http://blog.csdn.net/eshing/article/details/37521481 版权声明:本文为博主原创文章,未经博主允许不得转载. 一.启动过程说明 讲解启动过 ...