Change file privileges automatically


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change file privileges automatically
# 1  
Old 01-11-2009
Change file privileges automatically

Hi,
Is it possible to write and run a shell script for specific directory( Apache/htdocs) that changes root privilege read/write to chmod 755 when a program uploads a file (word,PPT,XSL,..) to that directory

Thanks,
Mk
# 2  
Old 01-11-2009
Quote:
Originally Posted by mkohan
Hi,
Is it possible to write and run a shell script for specific directory( Apache/htdocs) that changes root privilege read/write to chmod 755 when a program uploads a file (word,PPT,XSL,..) to that directory

Thanks,
Mk
Yes, of course it is possible.

One way to do it is to have a crontab script that looks for new files in the directory of interest, then changes permissions when a new file is detected.

Pretty simple .....

Depending on how your upload program works, you can use it to trigger the same script, so you don't have to run a crontab.
# 3  
Old 01-11-2009
Thanks for your reply.

The shell script should be aware all the time for that directory if any new file appears, change it to chmod 755 right away.
could you help to write that script?
Mk
# 4  
Old 01-11-2009
"right away" needs to be defined!

Whatever you do, you'll have to poll the directory at regular intervals to see if your new file's arrived. That interval could be anything from 1 second upwards. You should be aware though, that a process that's running continuously and checking every second may have an impact on the rest of the processes running on your machine.

Quote:
while true
do
if ls <file>
then
chmod 755 <dir>
else
sleep <duration>
fi
done
This is dangerous as it is a perpetual loop and doesn't have a way out. I'll leave you to work out the safety mechanisms! It works as the exit status of 'ls' is 0 (true) if the file exists.

HTH

Jerry
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

How to change the date automatically on script?

Hello Experts, There is a log file which has date stamp, I just wanted to change the date automatically on daily basis when it runs. Tried the below, but no luck. grep -i error /var/bv1to1_var/logs/bv03.bectondickinson.com/bvlog.out.`date +\%Y\%m\%d` | tee error_bv03.doc I would highly... (10 Replies)
Discussion started by: seenuvasan1985
10 Replies

2. Shell Programming and Scripting

How to use dir_colors to change color of files with executable privileges

I'm extremely new to UNIX/Linux so apologies if I screw up the terminology. I'm trying to figure out how to change the color of file names in BASH. For the most part I've got it working out but executable files are giving me some trouble. I'd like a certain file type (*.inp) to be a... (4 Replies)
Discussion started by: Caerus
4 Replies

3. Debian

Change the privileges needed to run a program

Hi everyone, I have an issue with a project of mine. I have to run a program on a terminal which requires to be logged in as su to have it run it. Given that I'm having problem to use expect to give the password I'd like to change the privilege of that program from SU to normal user ( I have the SU... (13 Replies)
Discussion started by: gaisselick87
13 Replies

4. UNIX for Dummies Questions & Answers

Dir and file privileges in AIX

I have a question, I know for privileges, 4-READ, 2-Write, 1-Execute, so if a file has 754 privileges then owner has all privileges, folks in his groups can Read and execute that file. Others can only read the file. So if there are three users A B C, A is the owner B is in GROUP AB and C is not... (1 Reply)
Discussion started by: Hangman2
1 Replies

5. Shell Programming and Scripting

Change root password automatically

I need to change root password automatically in some servers all three months. I want to run this process in one of the servers and reply it to the others. The password must be known by the administrator. (3 Replies)
Discussion started by: Alrica
3 Replies

6. Shell Programming and Scripting

automatically change owner and group

We have a program that when a new account is created using the webpage it creates a new directory on the linux filesystem for the account. The problem is the process that creates the directory is as root user, as I want ftpuser to be able to login I have to manually login and chown -R the... (1 Reply)
Discussion started by: borderblaster
1 Replies

7. Shell Programming and Scripting

Automatically change to Bash shell after login

Hi men, I think this must be a very common job. "How could to Automatically change to Bash shell after login and then jail user can only using this shell". I want monitor user works.However it just only effect on Bash shell. Consequently if the user change the shell it will be worthless. ... (4 Replies)
Discussion started by: tien86
4 Replies

8. Shell Programming and Scripting

How to change automatically the file names

Hi all, I need to replace automatically all special characters of one filename with some corresponding characters For example > ö --> oe ä --> ae .... If the special character comes more than one time, then all the coccuerences have to be replaced. I would like to have a... (6 Replies)
Discussion started by: MAKY
6 Replies

9. Shell Programming and Scripting

Script to automatically change password.

I want to write a script which will automatically take password sequentially from a file after every 10 days. i.e the passwd command should be executed automatically every 10 days and it should take the input from the password file sequentially. Has any1 got a solution?????????????? (1 Reply)
Discussion started by: rahulrathod
1 Replies

10. UNIX for Dummies Questions & Answers

How would I telnet & change user password automatically in a script

I would like to create a script that logs into a list of several servers 50+ and changes my password all at once. Every 60 days we are required to login to each system and change our passwords or else they expire and our login account is deleted. I have an idea on how I could do this but... (4 Replies)
Discussion started by: darthur
4 Replies
Login or Register to Ask a Question