Print questions from a questions folder in a sequential order


 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Print questions from a questions folder in a sequential order
Prev   Next
# 1  
Old 11-26-2010
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):

Code:
#!/bin/sh

echo Username
read i
echo Password
read j
Username=$i":"$j

valid=`grep -n $Username /$HOME/PhaseTest/userinfo | wc -l` 



if [ $valid -eq 1 ]
then
echo "********Welcome to Grounoch Marx University********"
date
#Display questions
cat questions
else
echo "Unauthorised user"
fi

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..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to print missing and keep sequential ordering if not found

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)
Discussion started by: cmccabe
4 Replies

2. UNIX for Dummies Questions & Answers

Vi questions

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)
Discussion started by: Pouchie1
2 Replies

3. Programming

C++ questions

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)
Discussion started by: bscot008
1 Replies

4. Programming

A few C questions

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)
Discussion started by: JayC89
5 Replies

5. Programming

Reading special characters while converting sequential file to line sequential

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)
Discussion started by: Rajeshsu
2 Replies

6. AIX

Basic AIX Print Queue Questions

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)
Discussion started by: alexop
0 Replies

7. UNIX for Dummies Questions & Answers

few questions

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)
Discussion started by: vivekshankar
5 Replies

8. UNIX for Dummies Questions & Answers

questions

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)
Discussion started by: tamemi
1 Replies

9. Programming

C questions

What does "extern" do? ex. extern int x; and another question, what about using static in functions? like: static void foo(), why? (2 Replies)
Discussion started by: Esaia
2 Replies
Login or Register to Ask a Question