I'd like to create a bash shell script that can run commands and provide input as if I was typing it on the terminal.
I have written bash shell scripts before and understand how to but I'm a bit confused on how it 'interfaces'.
Currently, I'm required to run fdisk and other terminal commands and then go through their option panel providing a set/specified input. It is taking too long and since it is constant, I was wondering then how I would go about it.
I get that a shell script is like if you were to type that command into the terminal. Thus, can I just literally write a script that says something like:
sudo fdisk /dev/sda d 1 d 2 n p 1
As an example where the single string entries are what I type on my keyboard as fdisk waits for commands. This doesn't seem valid but it may be.
Also, something I have to do after those commands run is unplug the drive and then continue running it. Am I able to implement that into my program to wait for me to unplug, and replug and then continue running automated script?
I appreciate all the help.