batch command in a shell script

How do I execute a batch command from a script, which "waits" with the next command until the first one has finished?

=======
A piece of my script looks like this:
#!/bin/sh
(...)
# run a long batch job:
./run_calculation.sh
# then rename resulting file:
mv output.dat backup.dat
(...)

=======
and the problem is that "mv" command executes BEFORE "run_calculation.sh" has finished!

Thanks for any help
Ivo

./run_calculation.sh && mv output.dat backup.dat

See the man page for the wait command.

There is also the "batch" command...

#!/bin/sh
(...)
batch <<EOF
# run a long batch job:
./run_calculation.sh
# then rename resulting file:
mv output.dat backup.dat
EOF
(...)

Thank you guys; however, none of these things seem to work :frowning:
(1)
"batch <<EOF..." and "wait" commands both produce the same message:
"Can't open /var/run/atd.pid to signal atd. No atd running?"

(2)
Placing "&&" after the executable name has no (desired) effect, whether the next command goes in the same or next line.

[1] The "batch" and "at" commands are run by the "at daemon" or "atd". If atd isn't running, then you can't use these commands.

instead of enabling stuff nor causing yourself all this bother why not just edit run_calculation.sh and add at the bottom 'mv output.dat backup.bat' at the bottom?

This is what I've done and it works.
The reason for this whole hassle was that it is a part of a loop.
But I put the contents of my calculation batch script into the main script, and it seems OK. :slight_smile:
Thanks
Ivo

PS.
Noe it looks like that:

(...)
for ((j=1; j<=$5; j++))
do
update_parameters < __inp000000__
done

$NAMDHOME/charmrun ++local ++p 2 $NAMDHOME/namd2 $2 >> $4.out &&

if [ ! -e $4.restart.coor ] || [ ! -e $4.restart.vel ] || [ ! -e $4.restart.xsc ]; then
echo "ERROR: not enough output files to restart a job"
exit 6
fi
mv -f $4.restart.coor $3.coor
mv -f $4.restart.vel $3.vel
mv -f $4.restart.xsc $3.xsc
(...)