意外的 EOF 在第 1 行中寻找匹配的 `"'... 是什么原因?
Unexpected EOF looking for matching `"'... in line 1. What gives?
我是运行集群计算系统上的以下slurm脚本。
#!/bin/bash
#
#SBATCH --job-name=R1.5-CG-nvtrun # create a short name for your job
#SBATCH --qos=short # _quality of service_
#SBATCH --nodes=1 # node count
#SBATCH --ntasks-per-node=12 # number of tasks per node
#SBATCH --cpus-per-task=1 # cpu-cores per task (>1 if multi-threaded tasks)
#SBATCH --mem=10GB # total memory requested
##SBATCH --mem-per-cpu=4G # memory per cpu-core (4G per cpu-core is default)
#SBATCH --gres=gpu:1 # number of gpurs per node
#SBATCH --time=7:00:00 # total run time limit (HH:MM:SS)
#SBATCH --mail-type=all # send email on job start, end, and fail
# The modules I need to run my job
module purge
module load intel/19.0/64/19.0.5.281 # for running gromacs
module load anaconda3/2020.7
conda activate data-analysis
# run the job
set -e
# keep track of the last executed command
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# echo an error message before exiting
trap 'echo "\"${last_command\" command filed with exit code $?."' EXIT
init=InitializeSystem
em=EnMinimization
nvt=NVT-Equilibration
npt=NPT-Equilibration
md=MolDynamics
for iteration in {1..5}
do
echo "iteration number $iteration"
echo "setting up editconf..."
# construct a box using editconf
gmx editconf -f ./${init}/BZCG.gro -o ./${init}/BZCG-in-box.gro -c -d 1.0 -bt cubic > ./${init}/editconf.txt 2>&1
echo "executed editconf!"
echo "setting up insert molecules..."
# insert 1000 molecules in a box
gmx insert-molecules -box 4.48 4.48 4.48 -ci ./${init}/BZCG-in-box.gro -nmol 600 -o ./${init}/BZCG-setup.gro > ./${init}/insert-molecules1.txt 2>&1
echo "executed insert molecules!"
echo "setting up grommp for em..."
# run a minimization script
gmx grompp -f ./${em}/minim.mdp -c ./${init}/BZCG-setup.gro -p ./${init}/topol.top -o ./${em}/BZCG-EnMinimized > ./${em}/grompp_em.txt 2>&1
echo "executed grommp em!"
echo "setting up mdrun for em..."
# run the molecular dynamics
gmx mdrun -v -deffnm ./${em}/BZCG-EnMinimized > ./${em}/mdrun_em.txt 2>&1
echo "executed mdrun for em!"
echo "setting up grommp for nvt..."
# run an NVT script
gmx grompp -f ./${nvt}/nvt.mdp -c ./${em}/BZCG-EnMinimized.gro -r ./${em}/BZCG-EnMinimized.gro -p ./${init}/topol.top -o ./${nvt}/BZCG-NVT-Eqbrt.tpr > ./${nvt}/grompp_nvt.txt 2>&1
echo "executed grommp for nvt!"
echo "setting up mdrun for nvt..."
# run the molecular dynamics
gmx mdrun -v -deffnm ./${nvt}/BZCG-NVT-Eqbrt > ./${nvt}/mdrun_nvt.txt 2>&1
echo "executed mdrun for nvt!"
echo "moving onto production..."
# run the production script
echo "setting up grommp for production run..."
gmx grompp -f ./${md}/md.mdp -c ./${nvt}/BZCG-NVT-Eqbrt.gro -t ./${nvt}/BZCG-NVT-Eqbrt.cpt -p ./${init}/topol.top -o ./${md}/BZCG-MolDynamics.tpr -maxwarn 1 > ./${md}/grompp_production.txt 2>&1
echo "executed grommp for production run!"
echo "setting up mdrun for production run..."
# run the molecular dynamics
gmx mdrun -v -deffnm ./${md}/BZCG-MolDynamics > ./${md}/mdrun_production.txt 2>&1
echo "executed production run!"
echo "start creating the rdf..."
gmx rdf -f ./${md}/BZCG-MolDynamics.xtc -s ./${md}/BZCG-MolDynamics.tpr -o rdf_.xvg -selrpos whole_mol_com -seltype whole_mol_com -cut 0 -rmax 2.226 << EOF
2
2
EOF
echo "rdf created!"
echo "deleting back-ups..."
for dir in ${init} ${em} ${nvt} ${npt} ${md}
do
rm ./$dir/\#* || true
done
rm \#* || true
echo "deleted back-ups!"
# run the analysis, update parameters
python update.py
done
我 运行 的所有 gmx
东西是一个名为 gromacs 的软件包。
此脚本的奇怪之处在于它按预期运行所有内容,执行 10 次迭代,但一旦完成,它会输出一条错误消息:
/var/spool/slurmd/job6141167/slurm_script: exit trap: line 1: unexpected EOF while looking for matching `"'
第 1 行怎么会有不匹配的 "
?
我在
下面有未缩进的 EOF
2
2
似乎是程序完成我希望它完成的工作的唯一方式。如果我在那里取消 EOF 的缩进,我会收到以下错误:
/var/spool/slurmd/job6141905/slurm_script: line 104: warning: here-document at line 84 delimited by end-of-file (wanted `EOF')
/var/spool/slurmd/job6141905/slurm_script: line 105: syntax error: unexpected end of file
/var/spool/slurmd/job6141905/slurm_script: exit trap: line 1: unexpected EOF while looking for matching `"'
此处错误的性质是什么,我该如何解决?
如果您对我有任何建议,我们将不胜感激。
您在行
中缺少 }
trap 'echo "\"${last_command\" command filed with exit code $?."' EXIT
^
可能是触发该错误的原因。
我是运行集群计算系统上的以下slurm脚本。
#!/bin/bash
#
#SBATCH --job-name=R1.5-CG-nvtrun # create a short name for your job
#SBATCH --qos=short # _quality of service_
#SBATCH --nodes=1 # node count
#SBATCH --ntasks-per-node=12 # number of tasks per node
#SBATCH --cpus-per-task=1 # cpu-cores per task (>1 if multi-threaded tasks)
#SBATCH --mem=10GB # total memory requested
##SBATCH --mem-per-cpu=4G # memory per cpu-core (4G per cpu-core is default)
#SBATCH --gres=gpu:1 # number of gpurs per node
#SBATCH --time=7:00:00 # total run time limit (HH:MM:SS)
#SBATCH --mail-type=all # send email on job start, end, and fail
# The modules I need to run my job
module purge
module load intel/19.0/64/19.0.5.281 # for running gromacs
module load anaconda3/2020.7
conda activate data-analysis
# run the job
set -e
# keep track of the last executed command
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
# echo an error message before exiting
trap 'echo "\"${last_command\" command filed with exit code $?."' EXIT
init=InitializeSystem
em=EnMinimization
nvt=NVT-Equilibration
npt=NPT-Equilibration
md=MolDynamics
for iteration in {1..5}
do
echo "iteration number $iteration"
echo "setting up editconf..."
# construct a box using editconf
gmx editconf -f ./${init}/BZCG.gro -o ./${init}/BZCG-in-box.gro -c -d 1.0 -bt cubic > ./${init}/editconf.txt 2>&1
echo "executed editconf!"
echo "setting up insert molecules..."
# insert 1000 molecules in a box
gmx insert-molecules -box 4.48 4.48 4.48 -ci ./${init}/BZCG-in-box.gro -nmol 600 -o ./${init}/BZCG-setup.gro > ./${init}/insert-molecules1.txt 2>&1
echo "executed insert molecules!"
echo "setting up grommp for em..."
# run a minimization script
gmx grompp -f ./${em}/minim.mdp -c ./${init}/BZCG-setup.gro -p ./${init}/topol.top -o ./${em}/BZCG-EnMinimized > ./${em}/grompp_em.txt 2>&1
echo "executed grommp em!"
echo "setting up mdrun for em..."
# run the molecular dynamics
gmx mdrun -v -deffnm ./${em}/BZCG-EnMinimized > ./${em}/mdrun_em.txt 2>&1
echo "executed mdrun for em!"
echo "setting up grommp for nvt..."
# run an NVT script
gmx grompp -f ./${nvt}/nvt.mdp -c ./${em}/BZCG-EnMinimized.gro -r ./${em}/BZCG-EnMinimized.gro -p ./${init}/topol.top -o ./${nvt}/BZCG-NVT-Eqbrt.tpr > ./${nvt}/grompp_nvt.txt 2>&1
echo "executed grommp for nvt!"
echo "setting up mdrun for nvt..."
# run the molecular dynamics
gmx mdrun -v -deffnm ./${nvt}/BZCG-NVT-Eqbrt > ./${nvt}/mdrun_nvt.txt 2>&1
echo "executed mdrun for nvt!"
echo "moving onto production..."
# run the production script
echo "setting up grommp for production run..."
gmx grompp -f ./${md}/md.mdp -c ./${nvt}/BZCG-NVT-Eqbrt.gro -t ./${nvt}/BZCG-NVT-Eqbrt.cpt -p ./${init}/topol.top -o ./${md}/BZCG-MolDynamics.tpr -maxwarn 1 > ./${md}/grompp_production.txt 2>&1
echo "executed grommp for production run!"
echo "setting up mdrun for production run..."
# run the molecular dynamics
gmx mdrun -v -deffnm ./${md}/BZCG-MolDynamics > ./${md}/mdrun_production.txt 2>&1
echo "executed production run!"
echo "start creating the rdf..."
gmx rdf -f ./${md}/BZCG-MolDynamics.xtc -s ./${md}/BZCG-MolDynamics.tpr -o rdf_.xvg -selrpos whole_mol_com -seltype whole_mol_com -cut 0 -rmax 2.226 << EOF
2
2
EOF
echo "rdf created!"
echo "deleting back-ups..."
for dir in ${init} ${em} ${nvt} ${npt} ${md}
do
rm ./$dir/\#* || true
done
rm \#* || true
echo "deleted back-ups!"
# run the analysis, update parameters
python update.py
done
我 运行 的所有 gmx
东西是一个名为 gromacs 的软件包。
此脚本的奇怪之处在于它按预期运行所有内容,执行 10 次迭代,但一旦完成,它会输出一条错误消息:
/var/spool/slurmd/job6141167/slurm_script: exit trap: line 1: unexpected EOF while looking for matching `"'
第 1 行怎么会有不匹配的 "
?
我在
下面有未缩进的 EOF2
2
似乎是程序完成我希望它完成的工作的唯一方式。如果我在那里取消 EOF 的缩进,我会收到以下错误:
/var/spool/slurmd/job6141905/slurm_script: line 104: warning: here-document at line 84 delimited by end-of-file (wanted `EOF')
/var/spool/slurmd/job6141905/slurm_script: line 105: syntax error: unexpected end of file
/var/spool/slurmd/job6141905/slurm_script: exit trap: line 1: unexpected EOF while looking for matching `"'
此处错误的性质是什么,我该如何解决? 如果您对我有任何建议,我们将不胜感激。
您在行
中缺少}
trap 'echo "\"${last_command\" command filed with exit code $?."' EXIT
^
可能是触发该错误的原因。