Error 'comando no encontrado' al ejecutar el script de shell

Error 'comando no encontrado' al ejecutar el script de shell
#!/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

Intenté ejecutar un script de shell pero aparece el siguiente error:

[gakubu@localhost Kenkyuu]$ pre.sh

/home/gakubu/FaSTAR2019/Bridget2019/Kenkyuu/pre.sh: línea 8: /home/gakubu/FaSTAR2019/Bridget2019/Kenkyuu/script.func: No existe tal archivo o directorio /home/gakubu/FaSTAR2019/Bridget2019/Kenkyuu /pre.sh: línea 30: set_variables: comando no encontrado /home/gakubu/FaSTAR2019/Bridget2019/Kenkyuu/pre.sh: línea: read_input: comando no encontrado /home/gakubu/FaSTAR2019/Bridget2019/Kenkyuu/pre.sh: línea: make_dir: comando no encontrado

...

[gakubu@localhost Kenkyuu]$

enter code here

¿Qué significa esto y cómo lo soluciono?

Respuesta1

El script tiene, en la línea 8, el siguiente código:

. ${FASTAR_DIR}/"script.func"

Esto genera un archivo en un directorio particular. Este archivo probablemente contenga definiciones de funciones de shell. El archivo no se encuentra, según el mensaje de error, y el efecto de no encontrar este archivo es que luego no se encuentran las funciones que define (estos son los errores de "comando no encontrado" que obtienes).

Se supone que el archivo script.funcestá disponible en el mismo directorio que el script. Si movió el script a donde se encuentra actualmente, pero olvidó mover el script.funcarchivo con él, entonces esta sería la causa del error.

No voy a comentar más sobre el script en sí, salvo decir que el uso de expansiones de variables sin comillas lo hace muy frágil y posiblemente inseguro.

información relacionada