'How to prompt the commands that are written in a text file previously for spike?

I am using Spike to run a RISCV CPU. I will write the same set of commands many times that I wrote below

run 100 
reg 0
run 100
reg 0
run 100
reg 0

I actually want to automatize the command that I give to the spike. For example, taking commands from a text file and giving it to the spike can be a solution. However, I couldn't make it by using the makefile or text to bash method. As expected it is because in each case (after the spike command is entered) the commands are not entered before the spike stopped. Is there a way to enter a command without waiting for the completion of the previous one? I will use an automatic keyboard tool to enter commands just like entering from the keyboard if I cannot find a way to do it.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source