I'm trying to create a script that creates scripts (and do other things). My problem is that these scripts created contain environment variables, and when actually running my script, they do not appear in the script.
#!/bin/bash
for i in {001..116}
do
rm job
cat > job <<!
#PBS -S /bin/bash
#PBS -N $i-Fe63S
#PBS -j oe
#PBS -q default
#PBS -l nodes=1:ppn=24
#PBS -l walltime=48:00:00
#PBS -V
cd $PBS_O_WORKDIR
/opt/openmpi/bin/mpirun -np 24 /opt/vasp/5.4/vasp.5.4.1/bin/vasp_std > log
!
mkdir $i
cp job $i/
done
In the resulting "job" file created, it attempts, but fails to find the $PBS_O_WORKDIR, so the resulting script is
#PBS -S /bin/bash
#PBS -N 116-Fe63S
#PBS -j oe
#PBS -q default
#PBS -l nodes=1:ppn=24
#PBS -l walltime=48:00:00
#PBS -V
cd
/opt/openmpi/bin/mpirun -np 24 /opt/vasp/5.4/vasp.5.4.1/bin/vasp_std > log
How do i modify the script, so the line in the result script is written "cd $PBS_O_WORKDIR" rather than "cd"?