Tag Archives: Permission Denied

Trying to create a script to run as root, permission denied

By DonnieNarco

Hello all, I am trying to create a script or a .command file that will run for me and my other techs on many, many Mac OSX computers that will add a file to the /etc/ folder called /etc/launchd.conf

Every time I try to run the script, I get “Permission Denied” when trying to put the file into the /etc/ directory.

The reason for this script is we will need to deploy this script quickly across many Macs, and it will only be run by myself or other admins. We just want to make it easier for us so we do not have to manually go to the /etc/ folder and create the launchd.conf file each time. I dont mind having to type in the root password at launch of this script, but I would prefer to not have to type in the root password each time…i would love it if this could be completely autonomous.

here are the two versions of code that I have tried so far, based on help from other Google inquiries:

Code:

#!/bin/bash

clear ; echo This script will put a system configuration file into your Mac OSX that will assist with UNIX permissions on the IFS

clear ;
echo Moving Working Directory to the System Directory
cd /etc/

echo Creating a new file with correct permissions, please have system root password ready...

sudo cat <> launchd.conf
umask 000
EOF
echo Process has completed, thank you.


and this:

Code:

#!/bin/bash

clear ; echo This script will put a system configuration file into your Mac OSX that will assist with UNIX permissions on the IFS
sleep 2
clear ;

chown root Test3.command
chmod u+s Test3.command

echo Moving Working Directory to the System Directory
cd /etc/
sleep 2
echo Creating a new file with correct permissions, please have system root password ready...
sleep 3
sudo cat < launchd.conf
umask 000
EOF
echo Process has completed, thank you.
sleep 2


Does anyone know how I can create this script for us to run?
Thank you very much.

From: http://www.unix.com/shell-programming-scripting/220907-trying-create-script-run-root-permission-denied.html