I think what I want to do is fairly simple; I would like to limit the total runtime of my callSite function to only x seconds; as I only want it to run, not necessarily connect. That part is being handled in a later part of my project.
I think what I would need to do is kill the process of callSite however I am running into some issues with doing that when using a timer as a loop that's being run in parallel.
#!/usr/bash
function timer {
for ((i=$1; i>0; i--)); do
printf "\rScript will finish in $i seconds."
read -s -n 1 -t 1 key
if [[ $key ]]
then
break
fi
done
}
function callSite {
sudo minicom Cisco -d $1
#configuration for the modem dialing program
}
timer 60 & callSite Boston && fg
#this is where one would enter the desired runtime of the process
What would you suggest I do to tie the timer and the minicom together so that the minicom process is killed once the specified amount of time has passed?