ubuntu脚本执行报错的检查思路

简介:

一、遇到的问题:

今天有朋友问我,说在CentOS上写好的脚本,在Ubuntu上没法正常使用,当时没在意,以为是权限没配置好,后来看了下,发现ubuntu跟CentOS的默认shell是不同的,如是记录下,避免以后忘记:

1
2
3
1、ubuntu默认的shell是连接到dash,而我们通常写的shell脚本使用的时 bash
2、 bash 和dash在一些方面是不兼容的。因此执行同一个脚本,两者结果不同,可能用./*sh可以执行,而sh *.sh报错。
3、Ubuntu之所以使用dash是因为其体积小,兼容性高,但是对于经常使用CentOS的人来说,这就比较悲剧,一些 bash 可执行的脚步在dash下不能执行了,脚本的可移植性不能保证。


二、解决方法:

1
2
1、检查脚本是否有x权限,如果有,则进行第二步
2、 sudo  dpkg-reconfigure dash,然后出现的界面中选择 NO









本文转自 冰冻vs西瓜 51CTO博客,原文链接:http://blog.51cto.com/molewan/1947107,如需转载请自行联系原作者
目录
相关文章
|
3月前
|
Ubuntu Shell
百度搜索:蓝易云【Ubuntu系统如何设置开机自启动shell脚本?】
现在,你的Shell脚本将会在Ubuntu系统开机时自动执行。请确保脚本中的逻辑是正确的,以免对系统造成不必要的影响。
32 0
|
4月前
|
Ubuntu Linux
Centos 7、Debian、Ubuntu中tree指令的检查与下载
Centos 7、Debian、Ubuntu中tree指令的检查与下载
|
5月前
|
Ubuntu Python
Python 记录在Ubuntu上的一次模块缺失的摸排检查工作
记录在Ubuntu上的一次模块缺失的摸排检查工作
40 0
|
5月前
|
Ubuntu
ubuntu报错:OpenSSL is not properly installed on your system.
ubuntu报错:OpenSSL is not properly installed on your system.
102 0
|
9月前
|
Ubuntu
Ubuntu 1604报错cannot create temp file for here-document: No space left on device,拓展sda容量解决之
Ubuntu 1604报错cannot create temp file for here-document: No space left on device,拓展sda容量解决之
161 0
|
4月前
|
Ubuntu 计算机视觉 C++
Ubuntu 20.04 编译 Opencv 4.11,详细步骤(带图)及报错解决,我的踩坑之旅~
Ubuntu 20.04 编译 Opencv 4.11,详细步骤(带图)及报错解决,我的踩坑之旅~
605 0
|
21天前
|
Ubuntu Unix Linux
【Linux/Ubuntu】Linux/Ubuntu运行python脚本
【Linux/Ubuntu】Linux/Ubuntu运行python脚本
|
5月前
|
存储 缓存 NoSQL
如何解决Ubuntu server 下 Redis安装报错:“You need tcl 8.5 or newer in order to run the Redis test”.
如何解决Ubuntu server 下 Redis安装报错:“You need tcl 8.5 or newer in order to run the Redis test”.
138 0
|
6月前
|
监控 Ubuntu 数据可视化
如何使用各种工具和命令来检查 Ubuntu 中的 CPU 使用情况?
如何使用各种工具和命令来检查 Ubuntu 中的 CPU 使用情况?
379 0
如何使用各种工具和命令来检查 Ubuntu 中的 CPU 使用情况?
|
6月前
|
监控 Ubuntu Linux
如何使用不同的方法和命令来检查 Ubuntu 中的 CPU 数量?
如何使用不同的方法和命令来检查 Ubuntu 中的 CPU 数量?
60 0
如何使用不同的方法和命令来检查 Ubuntu 中的 CPU 数量?

相关课程

更多