[问题]网卡驱动安装程序运行报错

sh/bash/dash/ksh/zsh等Shell脚本
回复
tomshi
帖子: 123
注册时间: 2006-12-25 21:15
送出感谢: 0
接收感谢: 0

[问题]网卡驱动安装程序运行报错

#1

帖子 tomshi » 2008-03-10 14:07

还是在这里问一下吧,原帖在这里:
viewtopic.php?t=108752

为了安装t60上的无线网卡驱动,我参照如下地址的步骤进行操作:
http://ubuntuforums.org/showthread.php?t=140085

但在运行load脚本的时候出现问题:

代码: 全选

zhanghong@T60:~/tmp/intel/ipw3945-1.2.2$ sudo ./load
./load: 5: Syntax error: "(" unexpected 
请问各位脚本高手,我应该怎么修改?还是说我的操作哪里有问题?

脚本如下

代码: 全选

#!/bin/sh
# Copyright (C) 2004-2005 Intel Corporation
MODULE=ipw3945

function check_root()
{
   [ `whoami` != "root" ] &&
      echo "You must be root to run this script." &&
      return 1
}

function unload()
{
   ./unload -ipw3945d=${path} || return 1
}

function load_pre
{
    for i in firmware_class; do
   if ! (lsmod | grep -q $i) && \
       ! (modprobe $i > /dev/null 2>&1 && LOADED="${LOADED}${i} ") && \
       ! (grep -q request_firmware /proc/kallsyms); then
       if [ ! -e /proc/kallsyms ]; then
      echo "Could not be determine if firmware_class is already loaded."
      echo "Attempting to load driver anyway..."
       else
      echo "Firmware capabilities not found.  See INSTALL."
      return 1
       fi
   fi
    done
}


function load_modules
{
    I_DEBUG=""
   
    for i in ieee80211; do
   modprobe ieee80211 ${I_DEBUG} && LOADED="${LOADED}${i} "
    done
   
    insmod ./${MODULE}.ko $@ && LOADED="${LOADED}${MODULE} "
}

function load()
{
   load_pre && load_modules $@ && {
      if [ -z "${LOADED}" ]; then
         echo "No modules loaded."
      else
         echo "Loaded: ${LOADED}"
      fi

      return 0
   }

   echo "Load failed."

   return 1
}

function parse_args()
{
        driver_args=
        while [ "$1" ]; do
                case $1 in
                -ipw3945d=*)
                        path=$1
                        path=${path/*=//}
                        shift
                        ;;
      
      --)
         shift
         break
         ;;

      *)
         driver_args="$driver_args $1"
         shift
         ;;
      esac
   done

   daemon_args=$@
   path=${path/%\//}/
   
   [ -x ${path}ipw3945d ] || {
cat << EOD
${path}ipw3945d does not exist or is not an executable.

You can specify the path for the ipw3945d via the -ipw3945d parameter:

   % ./load -ipw3945d=~/bin

The above will attempt to locate ipw3945d in the ~/bin directory.
EOD
      return 1
   }

}

unset LOADED

path=/sbin

parse_args $@ &&
unload &&
load $driver_args &&
echo -n "Loading ipw3945d."
${path}ipw3945d $daemon_args &&
echo -n "." &&
sleep 1 &&
echo -n "." &&
sleep 1 &&
echo "done." 
回复

回到 “Shell脚本”