trying to automate sudo, yes to all in term,shell script or applescipt

i am trying to create a script to automate building the install media for macs - mont, big sur, catalina, etc.

i run it now many different ways, but my main way is with a .sh script where i just have to put in my password and yes to all in terminal, where the shell script opens.

what i’m trying to do is build a .sh script (or .command or shell script in applescript) to run the full command and put in the password and yes to all.

when i run ubuntu commands, it’s something like this: sudo echo {password} | sudo -S -y {command}

so i’m looking to do the same thing with mac:
sudo [use given password] [yes to all questions] /Users/home/recovOS/Install-macOS-Big-Sur.app/Contents/Resources/createinstallmedia --volume /Volumes/1100

i can’t get the yes and password to work.

i’ve found this research:

for sudo’ing i’ve read that it is one of these formats:
echo -n password | sudo -S command
echo password | sudo -S command
sudo -S <<< “password” command

and for yes to all, i’ve found these:
yes |
or
yes y |
or
yes Y |

but when i put them all together, it doesn’t run. it says “…type (Y) then press return: Operation canceled.”

i understand i’m storing my password in stdin, but i’m almost always in a close network environment. so i’m fine with the security aspect of putting my password into this shell script.

i also know that i could do something like cliclick to just input the key stroke, but i’m trying to solve this with code in case something else comes up later that might need password and yes to all.

thanks

Hi lavinnyv. Welcome to MacScripter.

Since your post is a request for help, I asked Mark to transfer this topic to our general-enquiry AppleScript | Mac OS X forum. Hopefully someone will see it there and be able to answer your question. Code Exchange is for sharing working code you think may be interesting or useful to others.