forward/backward capable prompt


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting forward/backward capable prompt
# 1  
Old 08-17-2009
forward/backward capable prompt

Hi,

I would like to construct an interactive prompt for a series of bash shell scripts. This prompt will ask the user a series of questions, and the answers will determine which scripts are run, and in which order.

I am familiar with the "read" command, and have successfully constructed a simple prompt. However, due to the inherent nature of shell scripts, the prompt is only capable of going forward; ie question #1 is asked, and once an answer is entered, question #2 is asked. The user is not able to then go back to question #1, unless he/she quits and starts over.

Does anyone have any ideas on how to do this? Is there a command that orders the shell to jump backward/forward to a specific line number of the script? My thought is that if the user enters for example "b" (for back), the shell would then skip so many line #'s back in the script to where the previous question was asked. Any other ideas?

Thanks for any help,
Mike
# 2  
Old 08-17-2009
One way to do it:

Each step would be a function. Then you have a main loop that counts which step you're at. If the user enters "b" it will subtract 1 from the counter and then call the function associated with that step.
# 3  
Old 08-17-2009
Hi kodak,

That is a pretty cool suggestion. I had thought of making each question be a separate script and doing something similar, but this sounds much more efficient.

So I assume you would initially define all of the functions, then have a "while" loop which would be exited once the counter exceeded the number of questions?

Thanks again.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Boot Loaders

Is Unetbootin capable of making any iso file bootable

1)It is a great experience to achieve what I got today. I had downloaded GParted iso file (135 MB size). Now to make a bootable usb of it, I used unetbootin and to surprise I succeded in entering Gparted application and modified my partitions. Earlier I was in a notion that it is used only for... (0 Replies)
Discussion started by: ravisingh
0 Replies

2. AIX

DLPAR capable with IVM - checks to do

I cannot find the post with the comment that DLPAR capability was not working with IVM. The two commands that need to be run are (as root, padmin does not know this command): VIOS: lsrsrc IBM.MngNode CLIENTS: lsrsrc IBM.MCP Examples: # lsrsrc IBM.MngNode Resource Persistent Attributes for... (2 Replies)
Discussion started by: MichaelFelt
2 Replies

3. Ubuntu

Iptables forward traffic to forward chain!!!

Hi, I am new to linux stuff. I want to use linux iptables to configure rule so that all my incoming traffic with protocol "tcp" is forwarded to the "FORWARD CHAIN". The traffic i am dealing with has destination addresss of my machine but i want to block it from coming to input chain and somehow... (0 Replies)
Discussion started by: arsipk
0 Replies

4. UNIX for Dummies Questions & Answers

Help With Backward grep

hey, i got 2 files with the following content: file1: LOCAL_GSK1 50:01:24:80:45:f1:15:23 50:01:24:81:45:f1:15:23 50:01:24:82:45:f1:15:23 50:01:24:83:45:f1:15:23 LOCAL_GSK2 50:01:24:82:00:9c:d7:a7 50:01:24:82:01:bc:d7:a7 50:01:24:82:02:dc:d7:a7 50:01:24:82:03:fc:d7:a7 LOCAL_GSK3... (1 Reply)
Discussion started by: boaz733
1 Replies

5. AIX

PCs Capable of Running AIX

Does anyone know of any personal computers or very small servers capable of running AIX? I would like to buy one and set it up at home so I can play and learn at the same time. (3 Replies)
Discussion started by: svalenciatech
3 Replies

6. UNIX for Dummies Questions & Answers

Best current usb capable NAS release?

Hello all, In looking around I see write ups on FreeNAS but they all look to be older writeups... What seems to be the current best usb based release of Unix to host a home file server? (0 Replies)
Discussion started by: komputersman
0 Replies

7. Shell Programming and Scripting

Using sed to append backward slash before forward slash

Hi all, I need to know way of inserting backward slash before forward slash. My problem is that i need to supply directory path as an argument while invoking cshell script. This argument is further used in script (i.e. sed is used to insert this path in some file). So i need to place \ in front... (2 Replies)
Discussion started by: sarbjit
2 Replies

8. UNIX for Advanced & Expert Users

Substitute single backward-slash with the double backward-slash

Hi, I have a path like this c:\test\sample\programs, i need to change thiis to c:\\test\\sample\\programs. How to perform this? I tried tr command but it didn't help me. Thanks Vijayan (3 Replies)
Discussion started by: mvictorvijayan
3 Replies

9. UNIX for Dummies Questions & Answers

Importing a unix file dump into a PC capable database

My development team has been trying to figure out how to import a unix data dump into SQL Server or convert it into an intermediate file format for several days. The data dump in question looks like this: $RecordID: 1<eof> $Version: 1<eof> Category: 1<eof> Poster: John Doe<eof>... (7 Replies)
Discussion started by: DaltonF
7 Replies
Login or Register to Ask a Question