Fixer Debugging


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Fixer Debugging
# 1  
Old 10-29-2010
Fixer Debugging

hi all, would you please help me correcting and debugging this script: fx-permiss.sh which accepts a list of users as argument resiting those files permissions:
say our directory structure:
/home/erzal/file
/home/erzal/dire
/home/erzal/share
/home/erzal/share/file
/home/erzal/share/dire
1- If a user or more are given as arguments, the script should reset files permissions as follows:
a. Directory ~/share to 750 (if it exists).
b. All regular files inside ~/share to 744.
c. All directories inside ~/share to 750.
d. All other regular files in ~ to 600 and all other directories in ~ to 700.
e. files of other types are left as they are.

Code:
#!/bin/bash

for   user in $1 $2 $3 ; do
   if -d /home/$1/share ; then
      chmod  750 /home/$1/share ; else
      echo “No folder named “share” is in  $user home directory”
   fi

   find /home/$1/share -type f  -exec chmod 744 {} \;
   find /home/$1/share -type d -exec chmod 750  {} \;
   find ~ -type f -not \( -name share -o -name ~ \) -exec chmod  600
   find ~ -type d -not \( -name share -o -name ~ \) -exec chmod  700

shift
done
#2- If no arguments are give, the script  should identify normal users in the system (UID >= 500) and for each  user, reset files permissions as described above.
for User in $(cat  /etc/passwd) ; do
   UserId=$(echo $User | cut -d ":" -f 3)
   if  ($UserId -gt 500) ; then
      # All reset permission stuff here
    fi
done

#3-At end of execution, produce a file named  report.txt that contains a list of all files in the user's home  directory including full path, owner, group and permissions for each  file.
find . -ls | awk '{print $11 "\t"  $5 "\t" $6 "\t" $1}' | tee  report.txt
#it shoul be for all users
#where it should be saved?

chmod   755 fix-permiss
#for T.Issa, my id is 20347, ever puplished on Oct27 by 20347
exit 0


Last edited by pludi; 10-29-2010 at 06:41 AM.. Reason: code tags, please...
# 2  
Old 10-29-2010
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Debugging Help Needed

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! I am VERY much a neophyte with shell scripting. I am working on the following, 1. The problem statement, all variables and given/known data: "Create a script sends an... (7 Replies)
Discussion started by: doghouse308
7 Replies

2. Shell Programming and Scripting

Debugging functions

So here I have a simple function that I wish to debug. However, I am unable to debug the desired function even with set -o functrace enabled. Before resorting to asking this question, I had managed to find a possible solution that did not produce the desired results, which is located here. How... (5 Replies)
Discussion started by: BrandonD
5 Replies

3. Programming

c++ debugging

hey i have a problem with a switch case in program and the debugger is messy has hell ( we use normal VI and gdb in our schoool to make it more diffiacult) any way i have a problom where for some unknown reason the debugger just skips a switch statment as if it wasent even there the rest... (2 Replies)
Discussion started by: gotenxds
2 Replies

4. UNIX for Dummies Questions & Answers

blcr debugging

hey, can any one please tell me how can i debug blcr?? actually i have checkpointd a client using blcr and i want to check out what actually happens when we checkpoint any program. so i want to see what happen when we type $cr_checkpoint pid i mean i want to debug when i enter this... (0 Replies)
Discussion started by: pratibha
0 Replies

5. Homework & Coursework Questions

Fixer Debugging

School:Syrian Virtual University - Bachelor in Information Technology - Tutor: A.Issa - course: S10-iti320 hi all, would you please help me correcting and debugging this script: fx-permiss.sh which accepts a list of users as argument resiting those files permissions: say our directory... (0 Replies)
Discussion started by: erzal
0 Replies

6. Shell Programming and Scripting

script debugging

is there any way you can add a breakpoint in a script so you can stop on it? i have used -xv in my shebang but the script just runs and i want it to stop at a specific point in the script. appreciate any help. (1 Reply)
Discussion started by: npatwardhan
1 Replies

7. Programming

Need some help in debugging the C-Progam.

Hi i want to debug the C program with GDB debugger. I want to debug the program by line by line. I want to debug program like as we debug the program in Turbo-C using the F8. Can any one help me? I know i have to use single stepping. But i don't know how to use it. Any help can be appreciated..... (5 Replies)
Discussion started by: ps_sach
5 Replies

8. Solaris

debugging

when I tried to debug my application i got the following. gdb -v GNU gdb 6.6 file is in C and Xmotiff Languages (gdb) attach 25499 Attaching to process 25499 Retry #1: Retry #2: Retry #3: Retry #4: 0xfea40b68 in ?? () (gdb) where #0 0xfea40b68 in ?? () (0 Replies)
Discussion started by: satish@123
0 Replies

9. Solaris

debugging problem

OS : SOLARIS 10 debug tool :$gdb -v GNU gdb 6.6 compiler : $gcc -v gcc version 2.95.3 20010315 (release) When i tried to debug my application i got the following error. $gdb Pal GNU gdb 6.6 Copyright (C) 2006 Free Software Foundation, Inc. This GDB was... (2 Replies)
Discussion started by: satish@123
2 Replies

10. Shell Programming and Scripting

Regarding Debugging

Hi, If we want to debug a shell script, then set -vx has to be included in the begining of the script. Just i want to know what purpose -vx is used. Thanks in advace Sarwan (2 Replies)
Discussion started by: sarwan
2 Replies
Login or Register to Ask a Question