Erro 'comando não encontrado' ao executar o shell script

Erro 'comando não encontrado' ao executar o shell script
#!/bin/bash
# pre.sh revision 4.0.0  Date: 2011/12/24

### Path ###
FASTAR_DIR=$(cd $(dirname $0);pwd)

##### Function s #####
. ${FASTAR_DIR}/"script.func"

usage(){
  echo "Usage: " $COMNAME " [option]"
  echo "  option   : <NONE> ...... by 1 process"
  echo "             -n <CPUs> ... batch process by <CPUs> process"
  echo "             -all ........ batch process"
  echo "             -e .......... use exact wall distance mode"
  echo "             -metis ...... use pre-fastar metis version"
  echo "             -fsi ........ use pre-fastar metis version with FSI mode"
  echo "             -emetis ..... use pre-fastar metis version with exact wd mode"
  echo "             -efsi ....... use pre-fastar metis version with FSI and exact wd mode"
  echo "             -h .......... show this statement"
}

##### Function e #####

#======================================#
# Main                                 #
#======================================#
#=== initialize ===#
COMNAME=`basename $0`
set_variables
if [ $# -eq 1 ]; then
  case $1 in
    "-all" | "-e" | "-metis" | "-fsi" | "-emetis" | "-efsi") opt=$1      ;;
                                                       "-h") usage; exit ;;
                                                          *) usage; exit ;;
  esac
  cpu=1
elif [ $# -eq 2 ]; then
  case $1 in
    "-n") opt=$1      ;;
       *) usage; exit ;;
  esac
  if [ $2 -ge 1 ]; then
    cpu=$2
  else
    cpu=1
  fi
elif [ $# -gt 2 ]; then
  usage; exit
else
  opt="hoge"
  cpu=1
fi

#=== read inputfile ===#
read_input
case $reorder in
  ".true." | ".TRUE." | "T" | "t")
    reorder_check="TRUE"
    ;;
                                *)
    reorder_check="FALSE"
    ;;
esac

#=== ABORT ===#
trap 'abort 1 $COMNAME' 1 2 3 9 15

#=== Make directories ===#
make_dir

#=== preprocess ===#
if test $opt = "-all" ;then
  echo $NPREFAST...
  rm -f $TMP_FILE
  if [ $domain -ge 2 ]; then
    n_loop=$domain
    id=1
    for ((id=1; id<=$n_loop; id++))
    do
      echo "$NPREFAST $id  > $TMP_FILE$id &"
      $PREFAST $id  > $TMP_FILE$id &
    done
    wait

    i=1
    for ((i=1; i<=$domain; i++))
    do
      cat $TMP_FILE$i >> $TMP_FILE
      rm -f $TMP_FILE$i
    done

  elif [ $domain -eq 1 ]; then
    $PREFAST
    echo ""
  else
    echo "ERROR: It is wrong that total number of domain in $INPUT."
    exit
  fi

elif test $opt = "-n"; then
  echo $NPREFAST...
  rm -f $TMP_FILE
  n_loop=`expr $domain / $cpu`
  id=1
  i=1
  for ((i=1; i<=$n_loop; i++))
  do
    var=`expr $cpu \* \( $i - 1 \) + 1`

    id=$var
    j=1
    for ((j=1; j<=$cpu; j++))
    do
      echo "$NPREFAST $id  > $TMP_FILE$id &"
      $PREFAST $id  > $TMP_FILE$id &
      id=`expr $id + 1`
    done
    wait
  done

  if [ `expr $id - 1` -lt $domain ]; then
    while [ $id -le $domain ];
    do
      echo "$NPREFAST $id  > $TMP_FILE$id &"
      $PREFAST $id  > $TMP_FILE$id &
      id=`expr $id + 1`
    done
    wait
  fi

  i=1
  for ((i=1; i<=$domain; i++))
  do
    cat $TMP_FILE$i >> $TMP_FILE
    rm -f $TMP_FILE$i
  done

elif test $opt = "-e" ;then
  echo $NPREFAST...
  rm -f $TMP_FILE
  $PREFAST -e

elif test $opt = "-metis" ;then
  echo $NPREMETIS...
  rm -f $TMP_FILE
  $PREMETIS

elif test $opt = "-fsi" ;then
  make_dir_fsi
  echo $NPREMETIS...
  rm -f $TMP_FILE
  $PREMETIS FSI

elif test $opt = "-emetis" ;then
  echo $NPREMETIS...
  rm -f $TMP_FILE
  $PREMETIS -e

elif test $opt = "-efsi" ;then
  make_dir_fsi
  echo $NPREMETIS...
  rm -f $TMP_FILE
  $PREMETIS -eFSI

else
  echo $NPREFAST...
  rm -f $TMP_FILE
  $PREFAST
fi

#=== reorder ===#
case $reorder_check in
  "TRUE")
    echo $NREORDGRID...
    $REORDGRID
    echo $NREORDINDX...
    $REORDINDX
    ;;
esac

exit

Tentei executar um script de shell, mas aparece o seguinte erro:

[gakubu@localhost Kenkyuu]$ pre.sh

/home/gakubu/FaSTAR2019/Bridget2019/Kenkyuu/pre.sh: linha 8: /home/gakubu/FaSTAR2019/Bridget2019/Kenkyuu/script.func: Não existe tal arquivo ou diretório /home/gakubu/FaSTAR2019/Bridget2019/Kenkyuu /pre.sh: linha 30: set_variables: comando não encontrado /home/gakubu/FaSTAR2019/Bridget2019/Kenkyuu/pre.sh: linha: read_input: comando não encontrado /home/gakubu/FaSTAR2019/Bridget2019/Kenkyuu/pre.sh: linha: make_dir: comando não encontrado

...

[gakubu@localhost Kenkyuu]$

enter code here

O que isso significa e como posso corrigir isso?

Responder1

O script possui, na linha 8, o seguinte código:

. ${FASTAR_DIR}/"script.func"

Isso origina um arquivo em um diretório específico. Este arquivo provavelmente contém definições de funções do shell. O arquivo não foi encontrado, de acordo com a mensagem de erro, e o efeito de não encontrar esse arquivo é que as funções que ele define não são encontradas (esses são os erros de "comando não encontrado" que você obtém).

Presume-se que o arquivo script.funcesteja disponível no mesmo diretório que o próprio script. Se você moveu o script para onde ele está localizado atualmente, mas esqueceu de mover o script.funcarquivo com ele, essa seria a causa do erro.

Não vou comentar mais sobre o script em si, a não ser dizer que o uso de expansões de variáveis ​​sem aspas o torna muito frágil e possivelmente inseguro.

informação relacionada