hi all! i should say first that im very new to linux so please try to be explanatory with the answers you give otherwise im bound to ask a lot of annoying questions

im trying to write a bash script to generate a cpu load (at this stage i dont mind if its only approximate). my backgroud is in control systems engineering so once ive got the linux basics down then i will [hopefully] be able to refine the precision of the program. anyway, so far ive written the following 3 scripts:
#######cpu_load_caller.sh#######
echo "" > status.txt # erase the contents of status.txt
./cpu_load_monitor.sh &
i=0
while [ $i -lt $1 ]
do
./cpu_load_generator.sh &
i=`expr $i + 1`
done
exit 0
################################
#######cpu_load_generator.sh####
i=1
while [ $i -lt 500 ]
do
i=`expr $i + 1`
echo "GENERATING LOAD..." >> status.txt
done
exit 0
################################
#######cpu_load_monitor.sh######
i=0
while [ $i -lt 100 ]
do
top | head -15 | tail -9 >> cpu_load_monitor_output.txt
i=`expr $i + 1`
echo "MONITORING..." >> status.txt
done
exit 0
################################
the program is called from the terminal as
cpu_load_caller.sh 100
or 100 can be replaced with another number. theoretically the 100 value should produce 100 processes and thereby increase the cpu load for a while. at this stage im just trying to get it running without feedback - once i've acheived that then i'll clean up the output to cpu_load_monitor_output.txt so that it reflects the total cpu load in a single decimal value per line and then use that in cpu_load_caller.sh to tune the load.
however at the moment the program only spits out the error
top: failed tty get
which i guess means that the top function does not like running in the background? ive read a few similar posts in this forum which suggest using tokens or even moving the seperate shell scripts into functions all within the same file. if this is the way to go please let me know and i'll give it a bash and write back with my new script.
thanks for your time!