Синтаксическая ошибка при использовании End of Message (EOM) внутри цикла while в сценарии оболочки ubuntu

У меня есть код, содержащий команду, в которой пользователю предлагается выбрать вариант из тех, что показаны в меню. Это должно выполняться несколько раз несколько раз, поэтому я использовал цикл while. Теперь я использовал метод EOM (конец сообщения) для ввода данных при появлении запроса. При использовании я заметил, что этот метод вызывает следующую ошибку при выполнении. Я сузил ошибку до этой части кода ( строки с 80 по 83), и я не могу передать это.

Пожалуйста, помогите мне решить эту проблему.

Строки, в которых возникает ошибка:

TEMP="q"
gmx_mpi make_ndx -f pull_sim.gro -o index.ndx <<EOM
$TEMP
EOM

Ошибка:

./Run_Pull_Code.sh: 105: Syntax error: end of file unexpected (expecting "done")

Пожалуйста, найдите полный следующий код (см. в строки с 80 по 83 здесь):

#!/bin/sh
# The above comment sets the sh file to execute as an interpreter (Line by line)

# Finding the current working directory
BASEDIR=$(pwd)
echo "I am currently in the following directory:"
echo "$BASEDIR"
echo " "


##########################################################################################
# Setting the pulling code positions and decrements (All in nm)
##########################################################################################
DECREMENT=0.5      #Steps in nm
RANGE=1            #From the highest to the lowest position
MID_POS=9.327      #Observing the highest water molecule (O atom) of the water surface
INIT_POS=$( echo "$MID_POS + $RANGE" | bc -l)  # Initial position
LAST_POS=$( echo "$MID_POS - $RANGE" | bc -l)  # Final position
CURR_POS=$INIT_POS # Assigning the Initial position as the current position


LOOP_CNT=0
while [ 1 -eq "$(echo "${LAST_POS} <= ${CURR_POS}" | bc)" ]
do 
    # increment the value
    LOOP_CNT=$( echo "$LOOP_CNT + 1" | bc -l)
    DISTANCE=$CURR_POS

    # Setting the loop number (X) as the pull code number for simulation (X)
    SIM_CNT=$LOOP_CNT

    # Making the directories (1) X_Pull (2) X_Pull/Making
    DIR_NAME_MAIN=$SIM_CNT"_Pull"
    mkdir $DIR_NAME_MAIN
    DIR_NAME_MAKING=$SIM_CNT"_Pull/Making"
    mkdir $DIR_NAME_MAKING
    
    echo " "
    echo "I have made the directories."
    echo " "

    # Copying the files from prerequisites folder to the newly created folder
    cp Prerequisites/Avo_decanol.pdb Prerequisites/water_box.pdb $DIR_NAME_MAKING
    cp Prerequisites/simulation_file.mdp Prerequisites/topol.top $DIR_NAME_MAIN
    
    ##########################################################################################
    # Making the simulation box "pull_sim.gro"
    ##########################################################################################
    cd $DIR_NAME_MAKING
    #(1) Fix the distance of the decanol from the water surface and make the only decanol box with the same dimension as that of the water box
    DISTANCE=9.5 
    gmx_mpi editconf -f Avo_decanol.pdb -o Dec_box.pdb -center 2.5 2.5 $DISTANCE -box 5 5 12
    #(2) CREATING CONSTANT HEADER AND ENDER cat files in PDB format
    #The first 4 lines of any PDB file contains the information of the box size and the name, etc.
    #Just copy the four lines into a separate HEADER PDB file by the following command.
    sed -n '1,4p' Dec_box.pdb > HEADER.pdb
    #The last 2 lines are also common to all PDB files, hence copy these to a ENDER PDB file by the following command.
    sed -n '38,39p' Dec_box.pdb > ENDER.pdb
    #(3) Separate the decanol atom properties from its PDB file (line 5 to 37) by the follwing command
    sed -n '5,37p' Dec_box.pdb > file_1.pdb
    #(4) Separate the water atom properties from its PDB file (line 5 to 15004) by the follwing command
    sed -n '5,15004p' water_box.pdb > file_2.pdb
    #(5) Now connect all the above files with the water surface PDB file in the following sequence:
    cat HEADER.pdb file_1.pdb file_2.pdb ENDER.pdb > pull_sim.pdb
    #(6) Rearrange all the number of atoms in the pull_sim.pdb and convert it into a GRO file, pull_sim.gro file.
    gmx_mpi editconf -f pull_sim.pdb -o pull_sim.gro -center 2.5 2.5 6.0 -box 5.0 5.0 12.0 -resnr 1

    # Copying the recently made pull_sim.gro file from making folder to the previous folder
    cd ../
    cp Making/pull_sim.gro ./
        
    echo " "
    echo "The pull box has been created."
    echo " "
    
    ##########################################################################################
    # Starting the simulation
    ##########################################################################################
    # (1) Making index file
    TEMP="q"
    gmx_mpi make_ndx -f pull_sim.gro -o index.ndx <<EOM
    $TEMP
    EOM
    # (2) Creating tpr file from grompp module
    gmx_mpi grompp -f simulation_file.mdp -p topol.top -c pull_sim.gro -n index.ndx -maxwarn 0 -o nvt.tpr
    # Clearing all the contents
    clear
    echo " "
    echo "#####################*********** Pull Simulation: $LOOP_CNT ***********#####################"
    echo " "
    # (3) mdrun
    gmx_mpi mdrun -v -deffnm nvt -nb gpu -pme gpu -pmefft gpu -bonded gpu
        
    # Moving back to the main folder
    cd ../
    
    # Decrementing the distance for the next loop
    CURR_POS=$( echo "$CURR_POS - $DECREMENT" | bc -l)
done
    
#clear
echo " "
echo "Complete"
echo " "
0
задан 9 November 2021 в 15:16

0 ответов

Другие вопросы по тегам:

Похожие вопросы: