'Is it possible to open a terminal using "open -a Terminal" and then send commands to that new instance, automatically?

I'm currently creating an app for some co-workers to automate our process of starting/stopping our development environments at the push of a button using SwiftUI. I'm able to do what I need to but for one of the environments I have to run "yarn start" from a specific directory but trying to run that command via the application isn't working as there's permission problems since I believe it's the application attempting to run the exec, not the user. It also doesn't seem to have access to the $PATH variables, so my solution to this is to use a script to do what I need and pass the directory to the script, which still isn't working. I came across the "open -a Terminal" command and am able to open a new terminal as the user, but I'm not sure if it's possible to then send commands to that new terminal via the script. Can anyone assist?



Sources

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

Source: Stack Overflow

Solution Source