将shell脚本从Solaris移植到Linux

时间:2012-09-10 19:16:37

标签: linux shell solaris rhel5

这应该非常简单,但我不确定它在抱怨什么。

type=${1-"-Debug"};
version=${2-"-0"};
echo "We are going to be building eValuate in build mode: " $type
if [[ $version = -1 ]]
  then
  echo "We are going to be building eValuate with omniORB-4.1.4"
  else
  echo "We are going to be building eValuate with omniORB-4.0.4"
fi
if [ $PLATFORM = "HPUX" ]
then
    if [ $type = -release ]
    then
      export MAKEFILE_MAIN=$PWD/common/makefile/makefile.hp
      export MAKEFILE_DEFS=$PWD/common/makefile/makefile.hp.rls
      shift
    else
      export MAKEFILE_MAIN=$PWD/common/makefile/makefile.hp
      export MAKEFILE_DEFS=$MAKEFILE_MAIN
    fi

    elif [ $PLATFORM = "AIX" ]
    then
       mv $PWD/Calculations/CalculationSTD/makefileAIX $PWD/Calculations/CalculationSTD/makefile
       mv $PWD/Calculations/CalculationSTD/StandardCalculationAIX.cpp     $PWD/Calculations/CalculationSTD/StandardCalculation.cpp
       rm -r $PWD/Calculations/CalculationSTD/Carleton
       if [ $type = -release ]
       then
         export MAKEFILE_MAIN=$PWD/common/makefile/makefile.aix
         export MAKEFILE_DEFS=$PWD/common/makefile/makefile.aix.rls
         shift
      else
     export MAKEFILE_MAIN=$PWD/common/makefile/makefile.aix
     export MAKEFILE_DEFS=$MAKEFILE_MAIN
      fi
  fi

这似乎在Solaris和AIX上运行良好,但在Linux上,我收到此错误消息:

   : command not found 1:
   : command not found 2:
   We are going to be building eValuate in build mode:  -release
   ./setpath.sh1: line 22: syntax error near unexpected token `elif'
   '/setpath.sh1: line 22: `       elif [ $PLATFORM = "AIX" ]

为什么它不喜欢elif?或者,它是否抱怨别的东西?

1 个答案:

答案 0 :(得分:1)

最后得到了答案,这要归功于完全随机的事情,与格式有关:

我已经从我的Windows机器上传输了文件,我猜Linux只是一个无法处理它的婊子。 Solaris和AIX做得很好。

使用此命令。 dos2unix * .sh