Sponsored Content
Top Forums Shell Programming and Scripting Trying to create a script to run as root, permission denied Post 302793059 by DonnieNarco on Thursday 11th of April 2013 03:34:57 PM
Old 04-11-2013
Hammer & Screwdriver 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.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unable to run program, Permission denied

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)
Discussion started by: smartgupta
0 Replies

2. UNIX for Dummies Questions & Answers

Permission denied when changing root password after reset

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)
Discussion started by: darkone_d1_2000
0 Replies

3. Shell Programming and Scripting

shell script and Permission denied

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)
Discussion started by: Mumie
3 Replies

4. Shell Programming and Scripting

Can root user run chmod 000 permission shell script?

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)
Discussion started by: royalibrahim
1 Replies

5. UNIX for Dummies Questions & Answers

mkdir: cannot create directory `/builds/somedir/': Permission denied

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)
Discussion started by: Technext
5 Replies

6. AIX

Permission Denied issue on AIX 6.1 using Root

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)
Discussion started by: mcdsweet98
3 Replies

7. Shell Programming and Scripting

Help with Permission Denied on script with sed

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)
Discussion started by: smarty
5 Replies

8. Linux

/var/lock/subsys permission denied for root

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)
Discussion started by: flagman5
4 Replies

9. Red Hat

Mkdir: cannot create directory `/home/phpmy/html': Permission denied centos

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)
Discussion started by: jediwannabe
2 Replies
CLEANALLRUV.PL(8)					      System Manager's Manual						 CLEANALLRUV.PL(8)

NAME
cleanallruv.pl - Directory Server perl script for issuing a cleanAllRUV task SYNOPSIS
cleanallruv.pl [-v] [-Z serverID] [-D rootdn] { -w password | -w - | -j filename } -b basedn -r rid [-A] [-P protocol] [-h] DESCRIPTION
Creates and adds a cleanAllRUV task to the Directory Server OPTIONS
A summary of options is included below: -Z Server Identifier The server ID of the Directory Server instance. If there is only one instance on the system, this option can be skipped. -D Root DN The Directory Manager DN, or root DN. If not specified, the script will search the server instance configuration for the value. -w password The rootdn password. -w - Prompt for the rootdn password. -j password filename The name of the file that contains the root DN password. -b basedn The replicated suffix that needs to be cleaned. -r rid The replica ID that needs to be removed. -P Protocol The connection protocol to connect to the Directory Server. Protocols are STARTTLS, LDAPS, LDAPI, and LDAP. If this option is skipped, the most secure protocol that is available is used. For LDAPI, AUTOBIND is also available for the root user. -A Abort a cleanAllRUV task that is currently running. -v Display verbose ouput -h Display usage EXAMPLE
cleanallruv.pl -Z instance1 -D 'cn=directory manager' -j /tmp/pw.txt -b 'dc=example,dc=com' -r 87 -P STARTTLS Note: security must be enabled to use protocol STARTTLS. If STARTTLS is not available it will default to next strongest/available protocol automatically. cleanallruv.pl -j /export/rootdnpw.txt -b 'dc=example,dc=com' -A -r 87 DIAGNOSTICS
Exit status is zero if no errors occur. Errors result in a non-zero exit status and a diagnostic message being written to standard error. AUTHOR
cleanallruv.pl was written by the 389 Project. REPORTING BUGS
Report bugs to http://bugzilla.redhat.com. COPYRIGHT
Copyright (C) 2013 Red Hat, Inc. Mar 5, 2013 CLEANALLRUV.PL(8)
All times are GMT -4. The time now is 08:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy