Sponsored Content
Homework and Emergencies Homework & Coursework Questions Print questions from a questions folder in a sequential order Post 302475114 by moraks007 on Friday 26th of November 2010 12:47:03 PM
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..
 

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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. 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

7. 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

8. 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

9. 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
rmf(1mh)																  rmf(1mh)

Name
       rmf - remove folder

Syntax
       rmf [ +folder ] [ -help ] [ -[no]interactive ]

Description
       The  command  removes all of the messages within the current folder, and then removes the folder itself.  If there are any files within the
       folder which are not part of MH, they are not removed, and an error message is displayed.

       You can specify a folder other than the current folder by using the +folder argument.  If you do not specify a folder, and cannot find  the
       current folder, asks you whether you want to delete instead.

       If the current folder is removed, it makes current.

       Note that the command irreversibly deletes messages that do not have other links, so use it with caution.

       If  the folder being removed is a sub-folder, the parent folder becomes the new current folder, and tells you that this has happened.  This
       provides an easy mechanism for selecting a set of messages, operating on the list, then removing the list  and  returning  to  the  current
       folder from which the list was extracted.

       Using to delete a read-only folder deletes the private sequence and current message information from the file, without affecting the folder
       itself.	If you have sub-folders within a folder, you must delete all the sub-folders before you can delete the folder itself.

Options
       -help	 Prints a list of the valid options to this command.

       -interactive
       -nointeractive
		 Asks for confirmation before deleting a folder.  By default, deletes a folder and its messages without asking	for  confirmation.
		 If  you  specify  the	-interactive option, asks if you are sure before deleting the folder.  You are advised to use this option,
		 since when deletes a folder its contents are lost irretrievably.

Examples
       This example shows how asks for confirmation when the -interactive option is used:
       % rmf -interactive +test
       Remove folder "test"? y

Profile Components
       Path:   To determine the user's Mail directory

Files
       The user profile.

See Also
       rmm(1mh)

																	  rmf(1mh)
All times are GMT -4. The time now is 04:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy