how to write a script contain list of questions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to write a script contain list of questions
# 1  
Old 04-15-2009
how to write a script contain list of questions

hi
i want to write a script that contain questions upto 50..when i run the script it has to ask the questions one by one with options like a,b,c,d and user has to answer the each question and finally result (contain how many user selected correctly)
please help me...i need hints to do....
waiting for your valuble reply...
# 2  
Old 04-15-2009
please post what have you tried till now..
smells like homework for me
# 3  
Old 04-16-2009
how to write a script contain list of questions

thanks for your reply...
the problem is i dont no how to do..means where to start.. and clearly i have mentioned in my thread i need only hints to do..means that i want to know how to do...some steps(hints)...
i heard that we need to connect to database..etc...i am beginner to shell script..
# 4  
Old 04-17-2009
how to write a script contain list of questions

well...after googled a lot i got somwthing to do...
here is my code..

Code:
while read line
do
echo $line
done < questions.txt

and questions.txt contain all the questions..
the output is coming like this
Code:
srinivas@opensolaris:~$ ./tryingscript.sh 
capital of Hungery
a.budapest
b.paris
c.pitsburgh
d.i dont no
your choice:
The longest river in the world
a.ganga
b.nile
c.bramhaputra
d.dont no
your choice :

Niagara Falls was discovered by
a.jhonny
b.Louis Hennepi
c.kempson
d.adrew heko
your choice:
srinivas@opensolaris:~$

but it has to wait untill user submitted any option...but it is not waiting...
so any help....
# 5  
Old 04-17-2009
So your reading the questions from a flat file, and
I'm assuming everthing that was printed out in your
example (aside from your command line and system prompts)
is in that flatfile.

If so then my hint is that:

When the $line = "Your choice :"

you need to read user input.

Currently, your script does not do this.
# 6  
Old 04-17-2009
how to write a script contain list of questions

yes you are right..reading from a flat file..
but still i am confused...where i have to place that code..i tried..but no use....
can you tell me..
# 7  
Old 04-17-2009
I thought you were looking for hints.

Hint: After the echo of the line you need to stop
to collect user input.

Problem: You've redirected input into the while loop command.

Hint: You need to solve this problem for it all to work.

Hint: man your shell (i.e. man ksh) and look at the built in 'read' (not man read)

Hint: while in the shell man page, look up 'exec' too.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to write a script to match a searched name to a given list?

Full title: How to write a script to match a searched name to a given list, and then returns other names with the same properties Anyway, first time here, hi! So I'm taking an introductory course at uni and there's a question in our lab that asks us to write a script where a user can search a... (4 Replies)
Discussion started by: aheyhey
4 Replies

2. Shell Programming and Scripting

How to write script to scan ip list through Nessus?

Scripting language: Shell script I want to Scan IP's from IPlist.txt through Nessus using shell scripting language. Give the Input (IPlist) to nessus and generate Nessus report in xml or PDF form which is saved automatically on computer . Please help if any one has idea about how to write... (2 Replies)
Discussion started by: sk151993
2 Replies

3. Shell Programming and Scripting

One script and some questions

Hi, guys, With some guys' help, I made a shellscript used to create new users(attached at the bottom). I have some questions: a). I need to prompt users to enter their password in my script, but when users type in their password, it's visible on screen. Is there any ways to hide the STDIN or... (4 Replies)
Discussion started by: franksunnn
4 Replies

4. Shell Programming and Scripting

Find common entries in 2 list and write data before it

Hi all, I have 2 files: second file I want if entries in one file will match in other file. It shuld wite approve before it so output shuld be (1 Reply)
Discussion started by: manigrover
1 Replies

5. UNIX for Dummies Questions & Answers

Have a list of numbers, want to write code to manipulate them

I have a list of numbers in the format: 5 4 15 65 32 I want to write code to manipulate the list and give me 100 - x such that the list looks like: 95 96 85 35 68 How do I go about doing that? Thanks! (9 Replies)
Discussion started by: evelibertine
9 Replies

6. Homework & Coursework Questions

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... (19 Replies)
Discussion started by: moraks007
19 Replies

7. UNIX for Advanced & Expert Users

NFS export need to be able to write to directory but not list

My issue is I want an NFS share where I can write to the directory, but not list any of the files in there. (doesn't matter if someone knows the name can open the file). Have an NFS export for example: drwxrwxrw- 2 cranes staff 256 18 May 12:48 cranes The export will only... (1 Reply)
Discussion started by: Cranie
1 Replies

8. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

9. SCO

List of questions posted

I had a query with regard to the posting of questions on the forum, it is that how do we see the questions that we have posted separately. It should not be that we have to go inside the forum list and search for the question that we had posted. I hope, my question is clear. Please, help in... (1 Reply)
Discussion started by: ran_sush
1 Replies

10. UNIX for Dummies Questions & Answers

script questions

Does anyone know how to use shell scripts to write the following if input is a b c d I wnat output as d c b a Thanks (2 Replies)
Discussion started by: james94538
2 Replies
Login or Register to Ask a Question