changing permissions of a file whos name was passed to 755


 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions changing permissions of a file whos name was passed to 755
# 1  
Old 02-24-2010
Tools changing permissions of a file whos name was passed to 755

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

Write a shell script that gives a passed file the "755" access permissions. The shell script should:
Change permissions of the file whose name was passed to 755
The shell script should display a message that the named file (name to be displayed inside ") access change was made.
The shell script should output the result of the ls -l command for that file only.
 
Modify the script above so that it assigns a passed file a set of passed access permissions

2. Relevant commands, code, scripts, algorithms:



3. The attempts at a solution (include all code and scripts):
I am just unsure of what this is asking, I think I am making it more complicated than it is. I know how to change permissions using the chmod command but I always have done this from the command line. I also cant get the quoting part correct. i did :
"ls -l */755.*"
echo ""
is this wrong?


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Sage College, Albany NY, USA, Leroy, CSI221 Linux for Net. Admin.

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 02-24-2010
Some clues to get you started.

If an executable script called "myscript" was invoked from the command line as
Code:
./myscript myfilename 755

we can save the parameters into named environment variables called say filename from $1 and the permissions parameter (755) from $2.

Code:
filename="$1"
echo "The first parameter is: ${filename}"
perms="$2"
echo "The second parameter is: ${perms}"

If we want to find out the current directory listing for the file myfile we can extend the script by one line. Any line starting with a hash character (#) a comment line and will be ignored by the shell.

Code:
filename="$1"
echo "The first parameter is: ${filename}"
perms="$2"
echo "The second parameter is: ${perms}"
# Directory listing for file called myfile
ls -la "${filename}"

Now we understand script parameters, we can take the saved $2 (now called ${perms} ) and substitute it into a unix chmod command.

Your turn!

Last edited by methyl; 02-24-2010 at 06:16 PM.. Reason: After discussion with colleagues decided to put 755 on the command call to point the way.
# 3  
Old 02-25-2010
Thank you so much, I was just making it harder on myself- I never set variables, so it was coming out terribly messy. I can take it from here- thank you for shining a light for me! I'm a newbie.
# 4  
Old 02-25-2010
Good luck anix007 and welcome to our world.
# 5  
Old 02-26-2010
Open Resource?

I guess this would be considered and "Open Resource" ?
# 6  
Old 02-26-2010
This forum is the legacy of DECUS (1961) and similar parallel strong root forums who acknowledge that System Administrators and System Programmers often work alone but are part of a powerful global community.

Last edited by methyl; 02-26-2010 at 08:40 PM.. Reason: Date
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Changing file permissions of a file created by another user

Hi, I have used expdp for datapump. The .dmp file is created by the "oracle" user. my requirement is to make a zipped file of this .dmp file. What i am trying to do is change the permissions of this .dmp file from 0640 to 0644 and then do a gzip and zip it. Is there any way i can change... (3 Replies)
Discussion started by: qwertyu
3 Replies

2. Homework & Coursework Questions

changing permissions of a file whos name was passed to 755

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a shell script that gives a passed file the "755" access permissions. The shell script should: Change... (0 Replies)
Discussion started by: anix007
0 Replies

3. Shell Programming and Scripting

HELP changing file permissions

does anyone know how to write a script that will change file permissions. because the Admin blocked me from altering any of my files im only allowed to read and i heard a script like this can bypass it but i dont know how to write it. Display current users. Display user Ids only. Display... (10 Replies)
Discussion started by: live2learn
10 Replies

4. Cybersecurity

changing /cn@0:console file permissions

I'm doing a security sweep of a Sun Sol 5.8 system. The file: /dev/console, which links to /devices/pseudo/cn@0:console, has the following perms: crw--w--w- I would like to get rid of the world write permissions. I can change the file permissions, but as soon as log back in, they are changed... (4 Replies)
Discussion started by: ErnieG
4 Replies

5. UNIX for Dummies Questions & Answers

changing permissions on a 444 file (ie chmod 444)

if I have a file set to permisions 444 (r-- r-- r--) should anyone other than the owner and root be able to change these permissions or delete the file. Apologies if this is a no-brainer but I cant test it myself and someone in our organisation is playin around with files they shouldnt be (1 Reply)
Discussion started by: ajcannon
1 Replies

6. UNIX for Dummies Questions & Answers

Changing file permissions

Is there a way to change a unix user's default file permissions so that when he creates a file, by default permissions are 777??? Thanks! (7 Replies)
Discussion started by: FredSmith
7 Replies

7. UNIX for Dummies Questions & Answers

changing default file permissions

How can I change the default permissions that are assigned when I create a file? (By default the file has: -rw-r--r-- ..... I'd like it to be -rw-r----- How can I change this default behavior? (8 Replies)
Discussion started by: FredSmith
8 Replies

8. UNIX for Advanced & Expert Users

Changing file permissions on upload

Hello ! When I connect to a RH FTP server, the files I transfer (from my "windows computer") to this server have the following permissions : -rw------- but I would like those files to have the following permissions : - rw-rw-r-x How can I do that ??? :) Thanks for your help ! G. (6 Replies)
Discussion started by: guix
6 Replies

9. Shell Programming and Scripting

Changing Permissions

Is it possible to change the permissons for an entire directory in one shot? I'm telneting on to a linux server. ...just a beginner-- --Paul (4 Replies)
Discussion started by: pdavid
4 Replies

10. Shell Programming and Scripting

changing file permissions

Use the following to Change permission of fileB (fileB could be fileB*) to change its permission same as the permission of fileA. chmod `ls -l fileA | awk '{pr int "u+", substr($1,2,1), substr($1,3,1), substr($1,4,1), ",g+", substr($1,5,1), substr($1,6,1), substr($1,7,1), ",o+",... (0 Replies)
Discussion started by: gagansharma
0 Replies
Login or Register to Ask a Question