Unix Script Help Need
Hello,
Can anybody help me with a unix script project that I have no clue on starting it, and also I 'm not that much familiar with unix scripting. Don't get me wrong have little bit experience with Linux, but when comes to script I'm just a beginner. If any someone can assist me with project that would be great. At the bottom is the description of the project: PROJECT 3 Create your own shell that will allow you to change file status and copy from one directory to another. If someone can help with this project. Thanks Deven |
Welcome to LinuxQuestions
Per the LQ Rules, please do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and Google searches) and we'll do our best to help. Also, keep in mind that your instructor might also be an LQ member. |
What did you learn in Project 1 and 2 ?
Can you apply that to Project 3 ? Obviously your prof must have explained how to do what you need to do. Where are you stuck? |
Creating a shell isn't the same as creating a script, unless you mean to create a script that emulates a shell.
Kevin Barry |
I asked the professor to provided any example that help with doing this project, this what he provided:
Dear Deven: The menu structure I mentioned can be created with the following template: echo "Please choose a folder or file. If you choose a folder you will move into that folder. Enter nothing to exit." read choice if [ "$choice" != "" ]; then if [ -f $choice ]; then echo "$choice options:" echo "Type hide to hide file." echo "Type copypro to copy protect." echo "Type read to set ready only." echo "Type copy to copy a file from one directory to another." echo "Type exit to choose a different file." read op case "$op" in hide) # code for hide copy) # code for copy copypro) # code for copypro read) # code for read exit) # code for exit *) # code for error esac else cd $choice fi fi So if this what's looking for, then I do have the little bit idea. The only part I really stuck is creating a your shell. So, if someone can provided me the material, or guide me on getting the first part clear. Then I can work the project. Sincerely, Deven PS Moderator, I'm sorry about the rule, which I didn't follow. My mistake, and I'll make sure next time. |
As ta0kira stated ... are you sure your Prof asked to
Quote:
"Create your own shell script ..." These are two very different things. |
It seems clear from the professors reply:
Your professor has also provided the starting point for your homework: Code:
echo "Please choose a folder or file. If you choose a folder you will move into that folder. Enter nothing to exit." Where are you having difficulties? |
What does "copypro" mean?
Kevin Barry |
As in the professor's instructions copypro (copy protection)
All of the options seem to be permission related, therefore alot of this will probably fall down to using chmod. But there may well be some PAM in use, not being on the course I couldn't say for sure ;) |
The prof's code:
@deven1174: I dare you tell the prof all those things! |
Here's is professor comment:
Yes, file status means permissions enable/disable. I am assuming that you have to provide for all the options you have on lab2. The template I gave you goes beyond that. Lab2 solution: #!/bin/ksh cd North find ./ -type f -exec chmod 555 {} \; cd # in order for a file to be read only and not be useless, it must be executable. Doing chmod 444 as you did is no good. cd East find ./ -type f -exec chmod 333 {} \; cd cd West find ./ -type f -exec chmod 333 {} \; cd # In order to be copy protected, you must disable the read permission. Doing chmod 744 as you did is no good. cd South for var in *; do if [ -d "$var" ]; then cd $var for var in *; do if [ -d "$var" ]; then cd $var for file in *; do mv "$file" ".$file" done cd .. else mv "$var" ".$var" fi done cd .. else mv "$var" ".$var" fi done # South is more tricky. You do not want to hide the whole South structure, but just the files. So you have to use something like the code above, to find and hide only the files. I'm kind a beginner when comes to Unix Scripting. I don't mind learning it, but with Project3 is due tomorrow. I kind running out of time. If anybody could help with this Project. Than You for your help Deven |
You haven't actually posted code you've written yourself and tried...
Kevin Barry |
Quote:
Also, what shell? Here in Linux-land, we mostly use BASH, which is derived from the Unix Bourne shell. I'm not sure what all the differences are. As far as getting help here, the best thing at this point would be to take specific questions---show us your code (or what you have read), and tell us specifically what you don't understand. Quote:
|
So what you are saying (or quoting) is:
"Read only" equates to chmod 555 "$choice" "Copy protected" equates to chmod 333 "$choice" "Hide" equates to mv "$choice" ".$choice" "Copy" will require asking for the new location (and testing that it is a directory) It seems to me that you have everything, that your professor has all but spelt out the answer. |
Deven ... what we are saying here is ... you show us that you have made an effort in doing your own homework ... and then we will help by offering suggestions to specific points you are having problems with.
We will not do your assignment for you. Show us what you have done. |
All times are GMT -5. The time now is 12:22 PM. |