LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1029|回复: 4

执行一个setup.sh脚本时出错

[复制链接]
发表于 2007-2-23 08:14:29 | 显示全部楼层 |阅读模式
sh setup.sh
这样执行脚本setup.sh时出错,说函数未找到
见下

  1. uml@yzw:/cdrom$ sh setup.sh
  2. setup.sh: 9: function: not found
  3. x86
  4. uml@yzw:/cdrom$
复制代码

出现这个问题主要是什么原因?
发表于 2007-2-23 10:35:09 | 显示全部楼层
贴内容出来看看
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-2-23 23:38:22 | 显示全部楼层
  1. #!/bin/sh
  2. #
  3. # Product setup script - Loki Entertainment Software
  4. # Go to the proper setup directory (if not already there)
  5. cd `dirname $0`
  6. # Return the appropriate architecture string
  7. function DetectARCH {
  8.         status=1
  9.         case `uname -m` in
  10.                 i?86)  echo "x86"
  11.                         status=0;;
  12.                 *)     echo "`uname -m`"
  13.                         status=0;;
  14.         esac
  15.         return $status
  16. }
  17. # Return the appropriate version string
  18. function DetectLIBC {
  19.       status=1
  20.       if [ -f `echo /lib/libc.so.6* | tail -1` ]; then
  21.               if fgrep GLIBC_2.1 /lib/libc.so.6* 2>&1 >/dev/null; then
  22.                       echo "glibc-2.1"
  23.                       status=0
  24.               else   
  25.                       echo "glibc-2.0"
  26.                       status=0
  27.               fi        
  28.       elif [ -f /lib/libc.so.5 ]; then
  29.               echo "libc5"
  30.               status=0
  31.       else
  32.               echo "unknown"
  33.       fi
  34.       return $status
  35. }
  36. # Detect the Linux environment
  37. arch=`DetectARCH`
  38. libc=`DetectLIBC`
  39. # Find the installation program
  40. function try_run
  41. {
  42.     setup=$1
  43.     shift
  44.     fatal=$1
  45.     if [ "$1" != "" ]; then
  46.         shift
  47.     fi
  48.     # First find the binary we want to run
  49.     failed=0
  50.     setup_bin="setup.data/bin/$arch/$libc/$setup"
  51.     if [ ! -f "$setup_bin" ]; then
  52.         setup_bin="setup.data/bin/$arch/$setup"
  53.         if [ ! -f "$setup_bin" ]; then
  54.             failed=1
  55.         fi
  56.     fi
  57.     if [ "$failed" -eq 1 ]; then
  58.         if [ "$fatal" != "" ]; then
  59.             cat <<__EOF__
  60. This installation doesn't support $libc on $arch
  61. Please contact Loki Technical Support at support@lokigames.com
  62. __EOF__
  63.             exit 1
  64.         fi
  65.         return $failed
  66.     fi
  67.     # Try to run the binary
  68.     # The executable is here but we can't execute it from CD
  69.     setup="$HOME/.setup$$"
  70.     cp "$setup_bin" "$setup"
  71.     chmod 700 "$setup"
  72.     if [ "$fatal" != "" ]; then
  73.         "$setup" $*
  74.         failed=$?
  75.     else
  76.         "$setup" $* 2>/dev/null
  77.         failed=$?
  78.     fi
  79.     rm -f "$setup"
  80.     return $failed
  81. }
  82. # Try to run the setup program
  83. status=0
  84. rm -f "$setup"
  85. if ! try_run setup.gtk && ! try_run setup -fatal; then
  86.     echo "The setup program seems to have failed on $arch/$libc"
  87.     echo
  88.     echo "Please contact Loki Technical Support at support@lokigames.com"
  89.     status=1
  90. fi
  91. exit $status
复制代码

是我哪里没有配置好吗?
回复 支持 反对

使用道具 举报

发表于 2007-2-24 00:20:27 | 显示全部楼层
把funcation这个词去掉就可以运行了。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-2-25 20:03:00 | 显示全部楼层
Post by Yuri
把funcation这个词去掉就可以运行了。


我没写过脚本,去掉之后还可以正确执行吗?
还有如何在不改变这个执行脚本的情况下,执行它?比如修改环境配置等等
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表