2
votes

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
3
It might help if you explained how it work fails? What goes wrong on Red Hat? - Glen

3 Answers

2
votes

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
0
votes

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?

0
votes

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.