Mac package stuck in running

I have the below script to install a package on a Mac endpoint, but it is getting stuck on running status on the “wait installer -pkg” line, is there anything that I’m missing?

prefetch d4fede9543ed7f7ab24b2ec13d5c42c345f7c5ee sha1:d4fede9543ed7f7ab24b2ec13d5c42c345f7c5ee size:112506287 http://bigfixserver:52311/Uploads/d4fede9543ed7f7ab24b2ec13d5c42c345f7c5ee/installer.pkg.tmp sha256:6387953c47f19e9324e265a1d75ac5b3ee315493250e725356ed01d224d0f1c9
extract d4fede9543ed7f7ab24b2ec13d5c42c345f7c5ee

wait cp “{posix path of file “installer.pkg” of folder “__Download” of client folder of current site}” “/private/tmp/”
wait installer -pkg “/private/tmp/installer.pkg” -target / -allowUntrusted
delete “/private/tmp/installer.pkg”

Although I’m not an expert on MacOS, basic logic says that you should try and test anything locally if it’s not functioning remotely. Can you successfully run this command locally?

Running the command manually on terminal successfully installs the package

Btw, I found the solution on a separate thread