The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Scripts and changing users bonekrusher UNIX for Dummies Questions & Answers 1 02-05-2008 08:55 AM
changing permission using FTP panknil Shell Programming and Scripting 3 11-07-2007 08:08 PM
changing wtmp ownership and permission voa2mp3 Red Hat 1 10-15-2007 06:48 AM
Changing userID and Changing group and GID deal732 Shell Programming and Scripting 2 04-18-2007 10:09 AM
permission dozy UNIX for Dummies Questions & Answers 1 12-28-2004 11:00 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-17-2004
BigTool4u2 BigTool4u2 is offline
Registered User
  
 

Join Date: Nov 2002
Location: London
Posts: 31
changing permission using scripts

I have been trying to create a script that changes the user rights to read in the 'other' group across directories. The problem I'm having is that when i execute the script, the permissions of the directories remains the same.

HELP
  #2 (permalink)  
Old 04-17-2004
google's Avatar
google google is offline Forum Advisor  
Moderator
  
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
Lets see what you have done, please post your script, or at least the portion where you try and change directory permissions. In the mean time see man chmod
  #3 (permalink)  
Old 04-17-2004
BigTool4u2 BigTool4u2 is offline
Registered User
  
 

Join Date: Nov 2002
Location: London
Posts: 31
Got it sorted

Thanks for replying, I found out what I was doing incorrectly so I managed to get it sorted.
Cheers
  #4 (permalink)  
Old 04-17-2004
norsk hedensk norsk hedensk is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2002
Location: new york
Posts: 1,025
please post your solution in hopes that others with a similar problem can see your solution. also please describe what you were trying to do.
  #5 (permalink)  
Old 04-21-2004
BigTool4u2 BigTool4u2 is offline
Registered User
  
 

Join Date: Nov 2002
Location: London
Posts: 31
After creating the directories shown below, I wanted to create a script that would show the permission for these directories using the ls -ld command...

mkdir SPADE
cd SPADE
mkdir HARLEM BRONX HACKNEY WHITEHALL BARKING
cd HARLEM
mkdir CANADA SHOELY PALUVA DELOPS

So I created this little script....

echo "This script demonstrates the permission for the directories"
echo""
echo "Permission for the SPADE directory"
cd SPADE
ls -ld
echo ""
echo "Permission for the HARLEM directory"
cd HARLEM
ls -ld
echo ""
echo "Permission for the BRONX directory"
cd ..
cd BRONX
ls -ld
echo ""
echo "Permission for the HACKNEY directory"
cd ..
cd HACKNEY
ls -ld
echo ""
echo "Permission for the WHITEHALL directory"
cd ..
cd WHITEHALL
ls -ld
echo ""
echo "Permission for the BARKING directory"
cd ..
cd BARKING
ls -ld
cd ..
cd HARLEM
echo ""
echo "Permission for the CANADA directory"
cd CANADA
ls -ld
echo""
echo "Permission for the SHOELY directory"
cd ..
cd SHOELY
ls -ld
echo ""
echo "Permission for the PALUVA directory"
cd ..
cd PALUVA
ls -ld
echo""
echo "Permission for the DELOPS directory"
cd ..
cd DELOPS
ls -ld

Can this script be shortened to create the same results??
  #6 (permalink)  
Old 04-21-2004
norsk hedensk norsk hedensk is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2002
Location: new york
Posts: 1,025
yes, you could use a for loop and store each directory name in one single array. disregarding specific shell syntax, and the fact that i dont know offhand what shell can actually use arrays (if not you could store each name in a file and have the for (or foreach) loop run through the file), here is an out line of how that would work:

Code:
directories_a[4] = {HARLEM, BRONX, HACKNEY, WHITEHALL, BARKING};

directories_b[3] = {CANADA, SHOELY, PALUVA, DELOPS};

mkdir SPADE;
cd SPADE;

for(i = 0; i<=4; i++)
{
    mkdir $directories_a[i];
    var_permissions_a[i]+=`ls -d directories_a[i]`;
}

cd HARLEM;

for (y = 0; y<=3; y++)
{
    mkdir $directories_b[y];
    var_permissions_b[y]+=`ls -d directories_b[y]`;
}
then output whats stored in var_permissions_a and var_permissions_b.

now, please keep in mind that the code i just wrote above is just ment as a prototype, you will have to make it wokr with whatever language your script is in. that stuff up there becomes a mix of at least two different languages and wont run like that on anything




  #7 (permalink)  
Old 04-21-2004
google's Avatar
google google is offline Forum Advisor  
Moderator
  
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
yes! For starters, you can use the -p switch on the mkdir command. mkdir -p This will create all child directories under a parent if they do not already exist. Secondly, you can set the umask for the user that runs the script so that the directories are created with the desired level of permissions. Lastly, use the find command to search the directories for a given permissions level, or for any file that has permissions less than what you desire. Output these files, or change the permissions of these files with the find command.

See the following man pages for syntax:
man chmod
man mkdir
man find

Last edited by google; 04-21-2004 at 10:16 PM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0