How to change owner of script to root?

I’m trying to change the owner of a script to root? I need to do this to manage Valentina Server. The script is very simple:

chown root:admin $1

But I’m not sure how to use the script with the file that needs the root owner. When I execute the script in Terminal I get errors:

Trixis-iMac:~ beatrix_willius$ sudo /private/var/folders/yr/t1mywwrs1s1d0qv8cwv928240000gp/T/com.mothsoftware.mailarchiverxproadmin-temp1599715237 ‘/Users/beatrixwillius\ 1/Library/Application\ Support/Mail\ Archiver\ X\ Pro\ Admin/start_me.sh’
chown: /Users/beatrixwillius\: No such file or directory
chown: 1/Library/Application\: No such file or directory
chown: Support/Mail\: No such file or directory
chown: Archiver\: No such file or directory
chown: X\: No such file or directory
chown: Pro\: No such file or directory
chown: Admin/start_me.sh: No such file or directory

The problem seems to be the spaces in the path. I’ve also tried without the \ but I get the same errors. What am I doing wrong?

In the chown script, you need:

chown root:admin “$1”

ie: quotes around where the substitution will occur.

Then, when calling the above, no need to escape spaces in the path encapsulated with the single quotes, ie:

‘/Users/beatrixwillius 1/Library/Application Support/Mail Archiver X Pro Admin/start_me.sh’

I’ve only checked this very quickly here using echo and cd instead of chown, but I’m kind of sure the above will work.

Thanks, that was it. Now the script works in Terminal but not in code.