Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: ,

Sponsored Links



Unix Shell Script

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 12-08-2008
BlackSunReyes's Avatar
Member
 
Join Date: Feb 2006
Posts: 124
Unix Shell Script

My problem is as follows: I have a prompt asking the user to choose among several choices to read from a file, I would like to limit the choice of the user only, and with only two choices and recover the parameters choice selected.

Example:

1 Color: Green Code: 1
2 Color: Yellow Code: 2
3 Color: red Code: 3

Choice:
The parameters (Green 1) and (yellow, 2) and (red, 3) represents when viewing parameters $ 2 and $ 4.
If the user chooses options 1 and 3 on a table tab [i] should be filled with the parameters (green, 1 red, 3)

Thank you in advance for your help.
Reply With Quote
  #2  
Old 12-08-2008
Expertz's Avatar
Member
 
Join Date: Dec 2007
Posts: 1,432
Try this :

Code:
/bin/sh a=null while [ "$a" ] || [ ! "$ choices"]; do echo "choice:" read "choice" a = $ ($ echo choice | sed 's / [1-3] [1-3 ]//') done echo "bravo"
Reply With Quote
  #3  
Old 12-08-2008
BlackSunReyes's Avatar
Member
 
Join Date: Feb 2006
Posts: 124
It is not very clear, I have not grasped the purpose of your script from the fact (1.2) or otherwise: (
Reply With Quote
  #4  
Old 12-08-2008
Expertz's Avatar
Member
 
Join Date: Dec 2007
Posts: 1,432
My script meets your needs ^ ^. It asks the user a choice. Then, the response of the user will move in sed, and erase all the answers like "[1-3] [1-3]" ([1-3] = any number between 1 and 3 included). And the results are stored in the variable $ a. At this stage, if a $ applies "is that the answer in the form that you wanted.
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Unix Shell Script"
Thread Thread Starter Forum Replies Last Post
shell script SSH not working Lilya Software Development 9 16-10-2010 02:53 AM
Shell script with sed Ameeryan Software Development 5 23-12-2009 02:29 PM
Parsing the file in Unix shell script Macarenas Software Development 3 23-11-2009 11:32 AM
Need suggestion on book for Unix & shell scripting! SamsherR Software Development 2 11-02-2009 05:22 PM
How to develop an interactive script in Unix systems Allanoo Software Development 4 16-10-2008 05:29 PM


All times are GMT +5.5. The time now is 05:33 AM.