博客
关于我
02-dos2unix命令与windows编辑shell不可执行问题
阅读量:63 次
发布时间:2019-02-26

本文共 361 字,大约阅读时间需要 1 分钟。

在开发过程中,我曾经遇到过一个问题:在Windows下编写了一个shell脚本,但在Linux环境下执行时却出现了一些问题。经过仔细检查,我发现脚本中可能包含了一些特殊字符,这可能是导致执行失败的原因。

为了验证这一猜想,我使用了命令cat -A对脚本进行逐行查看。结果显示,脚本中确实存在一些不可见的字符,这些字符可能会干扰脚本的正常执行。为了解决这个问题,我尝试使用dos2unix工具将脚本转换为纯文本格式。运行之后,脚本看起来没有明显的变化,但在Linux环境下执行时,脚本终于顺利运行了。

通过这次经历,我意识到在开发shell脚本时,最好在Linux环境下完成编写和测试工作。这样可以避免由于Windows和Linux环境差异带来的问题。此外,定期使用工具检查脚本中的特殊字符,也是保证脚本稳定运行的重要步骤。

转载地址:http://ptzz.baihongyu.com/

你可能感兴趣的文章
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>
No new migrations found. Your system is up-to-date.
查看>>
No qualifying bean of type XXX found for dependency XXX.
查看>>
No resource identifier found for attribute 'srcCompat' in package的解决办法
查看>>
no session found for current thread
查看>>
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
查看>>
NO.23 ZenTaoPHP目录结构
查看>>
no1
查看>>
NO32 网络层次及OSI7层模型--TCP三次握手四次断开--子网划分
查看>>