Print questions from a questions folder in a sequential order
1.) I am to write scripts that will be phasetest folder in the home directory. 2.) The folder should have a set-up,phase and display files
I have written a small script which i used to check for the existing users and their password.
What I need help with: I have a set of questions in a file named questions,i want to be able to display questions one after the order,enter and answer and store my answer in a new file called results and be able to check if it is correct.I have questions 1 to 8. question example: 9. How would you create a new directory called docs?
a) makedocs
b) mkdir docs
c) create docs
d) none of these Enter answer
b Enter question number, N for next question, P for previous question or Q for done
n
Thanks.
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:
I want to be able to print questions from a questions folder in a sequential order,
enter an answer ,store it and be able to validate a correct answer to a result file in PhaseTest folder
2. Relevant commands, code, scripts, algorithms:
Script order
1.)set up
2.)username
3.)question/answer
4.)calculate the output of the test
3. The attempts at a solution (include all code and scripts):
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
De Montfort University,Leicester,Uk,lecturer Parminder,IMAT 5122
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).
Last edited by DukeNuke2; 11-26-2010 at 03:19 PM..
First, let me sincerely thank you for filling out the homework template. You would not believe how many students just can't be bothered...
So far so good...
Works, but may break on spaces. Better and less awkward as Username="${i}:${j}"
You don't need to check what grep prints, you can just check it's return value. It's silent, you don't see it, but all programs have one. Zero means success, nonzero means error.
You should put a ^ at the beginning of the pattern, and a $ at the end, to make sure grep has to match the entire and not just part of it.
Short form for /${HOME}/ is ~/
I need to see what the question file looks like to offer further suggestions.
Last edited by Corona688; 11-26-2010 at 02:11 PM..
Questions file has questions 1 to 8 as follows:
p { margin-bottom: 0.21cm; } 1. How would you create a new directory called docs?
a) makedocs
b) mkdir docs
c) create docs
d) none of these
2. How would you delete a file called textFile?
a) delete textFile b) remove textFile c) rm textFile d) none of these
3. How would you create an empty file called tempFile?
a) cat tempFile b) empty tempFile c) create tempFile d) touch tempFile
4. What is the command to read the content of a file?
a) cat fileName b) more fileName c) less filename d) all of above
5. What is the command to display a list of all files, including the hidden files?
a) ls -a b) ls -all c) display -hidden d) ls -l
6. What is the command to check current working directory?
a) cd b) ls c) pwd e) ped
7. How would you change permissions of a file called tempFile? The new permissions are rwx for user and for group and others no permission.
a) grant 700 tempFile b) chmod 700 tempFile c) grant 711 tempFile d) chmod 711 tempFile
8. What is the command to go to parent directory?
a) cd parent b) cd .. c) cd . d) all of above
I need help to print the questions one after the other by making use of "Enter N for next questions and P for previous question" in a command line
1) you should add a specific character before every lines that start by a number.
this way, you can use this character as a record separator and retrieve questions by there records number (easy using awk)
2) you should store the total number of record/questions into a variable, because you may need it :
- if you are at the last questions and press N "Next" into the menu, you could therefore go to question 1
- if you are in question 1 and press P "Previous" then you could easily go to the last equestions.
3) Since you are going to do repeted task (display question and ask choice) you should consider building that call into a function that would take (for example) the questions number as arguments
Last edited by ctsgnb; 11-29-2010 at 06:55 AM..
Reason: Initially posted a too complete solution that wouldn't help you to learn by practice
thanks it works but noticed this error display on the terminal screen,it is highlighted below:
8. What is the command to go to parent directory?
a) cd parent
b) cd ..
c) cd .
d) all of above
Enter your choice :
b Warning: unknown mime-type for "Enter question number, N for next question, P for previous question or Q for done" -- using "application/octet-stream"
Error: no such file "Enter question number, N for next question, P for previous quesWarning: unknown mime-type for "Enter question number, N for next question, P for previous question or Q for done" -- using "application/octet-stream"
Error: no such file "Enter question number, N for next question, P for previous question or Q for done"
Question:
1.) where will i place the code to check for my answers.I have an answers file with the correct answers in it. I want to be able to verify my answers
2.) where will place the code to read if a user as attempted the test before to stop such user from taking the test again
3.) how to exit the questions to output the result,say "5 out of 8"
you can add set -x at the beginning of your script to help you to troubleshoot it.
Try to locate the error (in ksh you can insert lines such as (in ksh)
If you want people to help you to troubleshoot your code, please post it.
1) locate which portion of code is fooling around.
2) understand what it does
3) read the error message, if sometimes they are not relevant, they often give clues
Reference (to previous post title): Help_Beginner in Unix
I need assistance in terms of troubleshooting this codes.Though it not complete for the required task,shedding of any idea will be appreciated.
the information about the code is the thread referenced above
thanks
---------- Post updated 12-01-10 at 09:11 AM ---------- Previous update was 11-30-10 at 06:31 PM ----------
1)Please explain or show what the correct line of code should be.
2)notice this error highlighted in the terminal when running the code: Warning: unknown mime-type for "Enter question number, N for next question, P for previous question or Q for done" -- using "application/octet-stream" Error: no such file "Enter question number, N for next question, P for previous question or Q for done"
how can I resolve this error.
thanks
Last edited by vbe; 12-01-2010 at 05:22 AM..
Reason: code tags...
The below awk in bold will look for the ids in file1 in $2 of file2 and if they match print the line in file2. If an id is missing or not found in file2 (like BMPR2 in line4 of file1) I can not figure out how to add it to them to the lines in the output as missing in $3 following the same format.... (4 Replies)
Hello,
I would like to know how we can highlight/select a section of a file in vi and delete that section if we don't want to use the dd command to delete one line at at time. There is one where we don't want to delete the whole line , but up to a certain word. (2 Replies)
1.) Let's say I have a list: apple1, apple2, apple3, apple4, apple5
Does anyone know how to display the txt file using c++?
Does anyone know how to insert apple6 into the text file using link list and show the whole list including apple6? (1 Reply)
Hi guys. I'm writing a basic script in C# and there's a few areas where I am stuck, and I was wondering if you may be able to help me?
1) Can you embed an image into the source code so it will show in the windows GUI?
2) Can you change the background of the GUI?
3) How do you add an .ico to... (5 Replies)
We have to convert a sequential file to a 80 char line sequential file (HP UX platform).The sequential file contains special characters. which after conversion of the file to line sequential are getting coverted into "new line" or "tab" and file is getting distorted. Is there any way to read these... (2 Replies)
Morning, All
I've been doing some work on AIX print queues, troubleshooting some underlying issues we've been having. In the process of this I've uncovered some potential gaps in our knowledge. Our typical setup is remote impact printers (In this case OKIML5520s, with NICs) and local queues... (0 Replies)
hi ,
i have got few questions
1) i created a file "-myfile" .how can i remove this?what command shud i issue
2) i used echo "TODAYS DATE" ; DATE..........but date is comoing in second line..how can i make it come in single line?
3) how can i list all files in a directory using for... (5 Replies)
Dear Guys ,
I have some Questions , i need to have answeres for .
1. now if i took a back up for /etc/passwd and /etc/shadow , like simple copy .. and Install a new system , and paste those two files to the new system ... are the passwords and user info. going to work ?? is it posibble ?
... (1 Reply)