Trying to create a script to run as root, permission denied
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 <<EOF >> 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 <<EOF > 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.
What if you create a different directory where you and the other sysadmins have write permission, have the script create the file in that different directory, and make /etc/launchd.conf a symbolic link to the file created in that different directory?
oh ok, I see what you are saying now. I will try that out.
I also have another way I am investigating now.
What I seem to have found is I can create one script that runs my second script as sudo (root), I am just trying to get it to be able to *find* that second script (like if I place both in a USB stick, how do i tell the terminal window to look in that same directory to find the second script.
When I ran my first script from the terminal command line as root, the script worked...that's why i created a second script to simply run my first as root.
here is what I have:
First Script: (Test3.command)
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 <<EOF >> launchd.conf
umask 000
EOF
echo Process has completed, thank you.
Second Script:
Code:
#!/bin/bash
sudo .~/Test3.command
How can I tell Mac OSX to look at the same directory that both scripts are in to run it? When I run the second script now, I get this output:
Code:
Last login: Thu Apr 11 14:04:12 on ttys001
XXXX-MacBookPro:~ jlemme2$ /Users/jlemme2/Desktop/ifs/Test6.command ; exit;
Password:
sudo: .~/Test3.command: command not found
logout
[Process completed]
And, as a second part, how would I combine these two scripts into one, if it was possible?
I am also researching myself, so if I figure out my own answer I will post it here. I do appreciate your assistance with this.
AFAIK, .~/Test3.command does not have a clear meaning.
. means current directory.
~ means home directory.
I don't think it makes sense to put them together, unless there is something I'm missing (always possible). Use . or ~ depending on the intent, but not both.
-------------------
To find the second script, you either need an absolute or relative path to the second script, or the second script needs to live in a directory that is in the PATH variable.
Did the script stuff run from your shell prompt, interactively? Who or what calls the script (and has to provide environment): cron, ssh, webserver, ???
for incompatibility installation problems, I've decided to reinstall Centos 6.3
as can be seem from the df output, I've partitioned both / and and /home directories
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda8 12G 5.3G 6.5G 45% /
tmpfs ... (2 Replies)
Hello
I have simple line of code here:
FILE *lockfp = fopen("/var/lock/subsys/processName", "w");
which is denied even running as root. The result is
locking failed for the following reason: Permission denied
How is this possible? Why is this happening?
Thanks for your... (4 Replies)
I am trying to develop a script to replace a lowercase URLs with an upper case URLs in HTM files.
Basically.. replace href="somelowercaseurl" with href="SOMEUPPERCASEURL". In place.
the href's are not located in any specific position in the file.
Here is my shell script :
export... (5 Replies)
I have the following problem on my AIX 6.1 server.
I logged in with Root ID to this folder etc/opt/symantec/scspagent/lib/instfunlib I try changing the folder permission but I keep getting this output :
chmod: /opt/symantec/scspagent/lib/instfunlib: Permission Denied
I did a listing on it... (3 Replies)
Hi,
I am trying to run a shell script which contains an mkdir command as part of the execution. The script fails with the following error:
mkdir: cannot create directory `/builds/somedir/': Permission denied
The user running the script is 'harry' and belongs to group 'school'.... (5 Replies)
Hi,
I have a shell script file which is set to access permission 000. When I login as root (sudo su) and try to run this script, I am getting the Permission denied error. I have read somewhere that root admin user can execute any kind of permission script. Then why this behavior? However, I can... (1 Reply)
Have the following in a .sh file.
printf "Installing ... \ r"
cd $ ORG_DIR / a_a
. / configure> error.log
Make 1> error.log 2> error.log
make install> error.log
But when I run I get the following.
install.sh: line 270:. / configure: Permission denied
make: *** No rule two make target... (3 Replies)
I have a Solaris 10 machine that I didn't know the root password to so I went into single user mode and removed the password from the shadow file and rebooted and I am able to login with no password now.
But my problem is that when I try to change the root password from no password to something... (0 Replies)
Hi All,
I am working on Solaris Sparc 9 and I developed application and in that I want to open any file when any action is happened but when I am trying to do the same.I am getting the error --
"Error launching /test.txt", "", "Process.execAndWait",
"java.io.IOException: Cannot run... (0 Replies)