Visit Our UNIX and Linux User Community


How to write a directory lock shell script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to write a directory lock shell script?
# 1  
Old 03-18-2010
How to write a directory lock shell script?

Hi there,

pleas I want this script urgently. how to lock a directory by shell script?
# 2  
Old 03-18-2010
Using chmod command you can achieve this.

Code:
for i in $@
do
        if [ -d $i ]
        then
                `chmod 000 $i`;
        else
                echo "$i not a directory"
        fi
done

You need to give the directories in the argument.

Last edited by murugaperumal; 03-18-2010 at 04:59 AM..
# 3  
Old 03-18-2010
Quote:
Originally Posted by murugaperumal
Using chmod command you can achieve this.

Code:
for i in $@
do
        if [ -d $i ]
        then
                `chmod 000 $i`;
        else
                echo "$i not a directory"
        fi
done

You need to give the directories in the argument.
Thank you very mush for you fast replay but i don't want to change the permission or encrypt the folder. i just want to lock by password could you write for me another script please
thanks
# 4  
Old 03-18-2010
Please visit the following URL
Password protecting a directory from displaying
# 5  
Old 03-18-2010
@thillai_selvan: That will only protect the directory from access via HTTP, and only if one is running Apache as the web server.

@joneggk: You'll be out of luck without any 3rd party software and/or encryption, as a regular UNIX can't regulate access to a directory without changing the permissions and/or ACLs, and even then it won't be password protected.
# 6  
Old 03-18-2010
okay so is there any 3rd party software? folder lock application for ubuntu? without encrypting the folder
# 7  
Old 03-18-2010
Let's get your requirements down, OK?
  • Are there multiple persons accessing the Ubuntu machine?
  • Are there multiple persons accessing the Ubuntu machine at the same time?
  • If at the same time, will they be accessing the directory at the same time?
  • What is the technological expertise of the people accessing the directory?
  • Is there a graphical desktop, or is this a server machine?
  • Do you need plausible deniability?

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to write a script that checks whether files are moving out of a directory.

I have a directory that has files going into it and moving out on a regular basis. The normal state of the directory would be to be empty. I need to write a script that will check to see if files are Not moving out of the directory. Any help would be most welcome. (4 Replies)
Discussion started by: RoBKoS
4 Replies

2. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

3. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

4. Shell Programming and Scripting

Shell scripting-I need a script which should watch a directory for a file with specific directory

I need a script which should watch a directory for a file with specific directory. If it finds a file in directory, it should search for few specific keyword in the file. if the keyword exists, it should trim string from specific column. The file should be moved to another directory and the a... (8 Replies)
Discussion started by: akashdeepak
8 Replies

5. Ubuntu

How to lock a file through UNIX KSH shell script?

I wrote two shell scripts in UNIX that renames the same file and scheduled them at the same time. The following are the steps that I followed:- 1. I wrote 2 scripts named s1.sh and s2.sh, both trying to add “exec_” prefix to the name of the files present in a folder i which already don't start... (4 Replies)
Discussion started by: piuli
4 Replies

6. UNIX for Dummies Questions & Answers

How do i lock a ksh shell script?

Hi, I have a ksh shell script that accesses databases to drop and create tables and the script also creates text files. This shell script is accessed thru a java application that i would like to turn multi-user, but the only way that i can do that is if I can figure out a way to lock the shell... (2 Replies)
Discussion started by: ndedhia1
2 Replies

7. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

8. Shell Programming and Scripting

Need to Write Shell Script based off of this shell command

I'm trying to read a bunch of log files and output the lines that contain particular strings. To accomplish this, I've been running the following from the command line: find . -name "*" | xargs grep " " | grep " " > output.txt Two grep statements are needed in case I'm looking for a... (3 Replies)
Discussion started by: Rally_Point
3 Replies

9. UNIX for Dummies Questions & Answers

how to write script to create directory

Please help. I am the beginner. Don't understand about archive file. How to create a directory for the files from each archive with name of directory which equivalent to the base name of the archive. eg I have file abc.txt. How can I create a directory name abc. Thank you (1 Reply)
Discussion started by: snail
1 Replies

10. Shell Programming and Scripting

to write a script to compare the file size in the current directory and previous dir

hi, i am new to this site. i want to write a script to compare the file size of the files in the current dir with the files in the previous directory. the files name will be same, but the filename format will be as xyzddddyymm.txt. the files will arrive with the month end date(i want to... (5 Replies)
Discussion started by: tweety
5 Replies

Featured Tech Videos