红帽兼容性

发布于 2024-08-04 01:41:01 字数 454 浏览 9 评论 0原文

以下代码在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无可置疑 2024-08-11 01:41:01

我这里有 Red Hat Enterprise Linux 和 CentOS 盒子(我知道它们是同一件事),

该脚本对我来说在这两个盒子上的工作原理相同,所以我真的不明白 OP 的问题。

-bash-3.2$ ./foo.bash foo other_routes
first if successful
-bash-3.2$ ./foo.bash foo routes
first if successful
-bash-3.2$ ./foo.bash foo bus_stops
elif successful
-bash-3.2$ ./foo.bash foo another
else succsesful

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.

-bash-3.2$ ./foo.bash foo other_routes
first if successful
-bash-3.2$ ./foo.bash foo routes
first if successful
-bash-3.2$ ./foo.bash foo bus_stops
elif successful
-bash-3.2$ ./foo.bash foo another
else succsesful
握住你手 2024-08-11 01:41:01

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?

浅忆 2024-08-11 01:41:01

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文