2

以下代码在 CentOS 和 Ubuntu O/s 上按预期工作,但在 Red hat 上不正常。需要做出哪些改变?

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
4

3 回答 3

2

我这里有 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
于 2009-09-04T13:17:13.017 回答
0

CentOS == 红帽。你的问题没有意义。您使用的是什么版本的 bash?你期望什么输出,你会得到什么?

于 2009-09-04T13:15:53.517 回答
0

CentOS!=RHEL。我看不出你的断点在哪里,但我有两个系统都在运行,并且确实存在一些差异,至少如果你也使用 RHEL 的话。甚至在 RHEL 中的 CentOS 上也不存在一些完整的功能,尽管版本和内核匹配,但在它们之间移植脚本时我确实遇到了问题。

于 2013-03-22T19:29:08.317 回答