looking for help on script to capture file permission.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting looking for help on script to capture file permission.
# 1  
Old 11-15-2010
looking for help on script to capture file permission.

Hi Guys,

I'm a DBA and need help on shell scripting.
My Oracle Database is sitting on HP-UX machine.

Anyone has a script that can spool out permission of all oracle binary files in the below directory:
/opt/ora10g/oracle/

Format to be spooled out : chmod <exisiting permission> filename

I need to spool out in that format so that i can re-apply the privileges to all the files after upgrade of oracle.

thanks
# 2  
Old 11-15-2010
With GNU find you could try this:
Code:
find /opt/ora10g/oracle/ -printf "chmod %m %p\n" > restore_ora_perms.sh

This is just permissions, not ownership, but that would be easy to add..
# 3  
Old 11-15-2010
hmm I do not have GNU in my box. Anyway to shell script it?

thanks!
# 4  
Old 11-15-2010
Couldn't you download and install a findutils depot?
# 5  
Old 11-15-2010
Code:
 
#!/bin/ksh
find /opt/ora10g/oracle/ -name "*" | while read file
do
       if [ "$file != "." -a -f $file ]
             echo $file >> temp.txt
             ls -l $file | awk '{ print $1 }' | cut -c 2-10 | sed -e 's/[rwx]/1,/g' -e 's/-/0,/g' | awk '{ split($1, arr, ","); a=4*arr[1] + 2*arr[2] + 1*arr[3]; b=4*arr[4] + 2*arr[5] + 1*arr[6]; c=4*arr[7] + 2*arr[8] + 1*arr[9]; printf("chmod %d%d%d \n",a,b,c); }' >> temp1.txt
       fi
done
paste -d" " temp1.txt temp.txt >> restore_prem.ksh
rm -f temp.txt
rm -f temp1.txt

# 6  
Old 11-15-2010
Code:
find /opt/oracle -type f -depth -print | sed -e 's:^:chmod 777 :'  > /tmp/changperm.ksh

Or what ever your permissions what to be than run the file /tmp/changeperm.ksh

Last edited by Scott; 11-15-2010 at 11:39 AM.. Reason: Code tags, please...
# 7  
Old 11-15-2010
You might as well do
Code:
chmod -R $perm /opt/ora10g/oracle

then, no?
The idea is to restore the permissions to whatever the way it was before the Oracle upgrade (777 is a no-no by the way.)
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help on script to capture info on log file for a particular time frame

Hi I have a system running uname -a Linux cmovel-db01 2.6.32-38-server #83-Ubuntu SMP Wed Jan 4 11:26:59 UTC 2012 x86_64 GNU/Linux I would like to capture the contents of /var/log/syslog from 11:00AM to 11:30AM and sent to this info via email. I was thinking in set a cron entry at that... (2 Replies)
Discussion started by: fretagi
2 Replies

2. Shell Programming and Scripting

Script to capture string in a log file

Dear all, I have a log file to be analysed. this log file contains vaiours lines of code starting with date timestamp. if my search string is exception then that resepective log statement starting from the date is required. example: 2014/10/01 16:14:44.459|>=|E|X|19202496|2832|... (5 Replies)
Discussion started by: shravee
5 Replies

3. Shell Programming and Scripting

set -x within script and capture as a file

Okay, I've been working on a script for providing information on the progress of a backgrounded ditto command. Thanks to google and a lot of searching I've resolved all but one very odd error. At this point, I want to use xtrace (set -x) to try to uncover the issue. I have found several examples... (2 Replies)
Discussion started by: reid
2 Replies

4. Shell Programming and Scripting

AWK Script to Capture Each Line of File As Variable

Hi All, I'm working on creating a parts database. I currently have access to a manufacturer database in HTML and am working on moving all of the data into a MySQL db. I have created a sed script that strips out the HTML and unnecessary info and separates the script into one line for each field.... (3 Replies)
Discussion started by: dkr
3 Replies

5. Shell Programming and Scripting

shl script capture a file

need to be able to capture a file with the following conditions: The filenames are, for example, 3526_332840.dat, where 3526 is constant, and 332840 is a sequential number which is always a couple hundred greater than the previous day's file. I want to be able to change this script to acoomplish... (1 Reply)
Discussion started by: rechever
1 Replies

6. Shell Programming and Scripting

script to capture content of deleted file

I need to capture the content of a file before its being deleted. This file gets deleted immediately after it is created. I use the below shell command in the command prompt, but I'm not getting the desired result. bash-3.00# while true; do cat file* > tempfile; done; What I'm trying here... (5 Replies)
Discussion started by: bjawasa
5 Replies

7. Shell Programming and Scripting

Capture Shell Script Output To A File

Hi, I am running a shell script called dbProcess.sh which performs shutdown and startup of various Oracle instances we have.At the time of execution the script produces the following output to the command line window $./dbProcess.sh stop #### Run Details ###### Hostname : server-hop-1... (4 Replies)
Discussion started by: rajan_san
4 Replies

8. Shell Programming and Scripting

Script to capture new lines in a file and copy it to new file

Hi All, I have a file that gives me new line/output every 5 minutes. I need to create a script that capture new line/output besides "IN CRON_STATUS", in this case the new output is "begin ------ cron_status.sh - -----------". I want this script to capture the line starting from "begin ------... (0 Replies)
Discussion started by: fara_aris
0 Replies

9. Shell Programming and Scripting

file permission script

Hi all, I need one script, that will give the out put like all files having 777 permissions and full path from home directory. example:i created 777 permissions files three in my home directory and subdirectories also. i want out put like ./xxxxx/aaa.txt ./xxxxx/zzz/yyy.txt ... (3 Replies)
Discussion started by: krishna176
3 Replies
Login or Register to Ask a Question