红帽兼容性
以下代码在 CentOS 和 Ubuntu O/s 上按预期工作,但在 Red hat 上则不然。需要做出哪些改变?
CentOS 版本 5.3(最终版) Linux ubuntu 2.6.24-19-generic #1 SMP 6 月 18 日星期三 14:43:41 UTC 2008 i686 GNU/Linux
#!/bin/bash
depot=$1
table=$2
database=$3
combined="$depot$table"
if [ "$table" = 'routes' -o "$table" = 'other_routes' ]; then
echo 'first if successful'
elif [ "$table" = 'bus_stops' ]; then
echo 'elif successful'
else
echo 'else succsesful'
fi
The following code works as expected on CentOS and Ubuntu O/s but not on Red hat. What changes needs to be made?
CentOS release 5.3 (Final)
Linux ubuntu 2.6.24-19-generic #1 SMP Wed Jun 18 14:43:41 UTC 2008 i686 GNU/Linux
#!/bin/bash
depot=$1
table=$2
database=$3
combined="$depot$table"
if [ "$table" = 'routes' -o "$table" = 'other_routes' ]; then
echo 'first if successful'
elif [ "$table" = 'bus_stops' ]; then
echo 'elif successful'
else
echo 'else succsesful'
fi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我这里有 Red Hat Enterprise Linux 和 CentOS 盒子(我知道它们是同一件事),
该脚本对我来说在这两个盒子上的工作原理相同,所以我真的不明白 OP 的问题。
I've got both Red Hat Enterprise Linux and CentOS boxes here (I know they're the same thing)
That script works the same on both of them for me, so I really don't understand the OP's question.
CentOS == 红帽。你的问题没有意义。您使用什么版本的 bash?您期望什么输出,您会得到什么?
CentOS == RedHat. Your question doesn't make sense. What versions of bash are you using? What output do you expect, and what do you get instead?
CentOS!=RHEL。我不知道你的断点在哪里,但我运行了两个系统,并且确实存在一些差异,至少如果你也使用 RHEL。甚至一些完整的功能在 CentOS 上不存在,而在 RHEL 中,我在它们之间移植脚本时确实遇到问题,尽管版本和内核是匹配的。
CentOS!=RHEL. i don't see where your breaking point is, but i have both systems running and there are some differences indeed, at least if you too use RHEL. even some whole functions are not present on CentOS which are in RHEL and i do experience problems when porting script betwen them every now and then although release and kernel are matching.