Need help setting up a script to change date and time Mac OS Catalina hoping someone can help with this. I am trying to write an automator terminal script in Mac OS Catalina that will turn off WiFi, turn off automatic date and time settings, and set my mac to a specific system date and time. I have really no programming experience but what I have so far works to turn off wifi and change the system date and time...but the script will not exit in automator...it just keeps spinning. Not sure how to get the Sudo -S command to exit once it sets the system date and time. Here's what I have so far:

networksetup -setairportpower en0 off

echo "password" | sudo -S date 0101000120

So this will turn off wifi, and will pass my password (can also do it through a dialog but thats not my problem) and will set the system date...then the automator wheel just spins....


Any ideas how to get the terminal script to exit and move on to the next command...or should I just run it and then quit the script as its spinning which isn't ideal but also works
command to turn on and off auto updating of mac system date and time?


Thanks so much for reading and greatly appreciate any help.

EDIT: Currently re-wrote the automator task to run the terminal command, ask for a password then pass that on:

networksetup -setairportpower en0 off
pw="$(osascript -e 'Tell application "System Events" to display dialog "Password:" default answer "" with hidden answer' -e 'text returned of result' 2&gt;/dev/null)" &amp;&amp; / echo "$pw" | sudo -S date 0101000120

Still spins the wheel in an infinite loop at the end but I can click it and force stop. Anyone knows a way to just get it to stop appreciate it!
I could get this to work by piping the password to sudo from a file instead of using echo: 

sudo -S date 0101000120 &lt; ~/passwd.txt


I'm not sure what security implications this has though, but it feels wrong ...

If you're after a quick and dirty solution then this will do it, however as per nohillside's comment, here are some instructions to run sudo commands without requiring a password. These suggestions work for me on Mojave in iTerm2 and terminal.