The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Getting user input stevefox Shell Programming and Scripting 3 02-15-2007 11:09 PM
Creating a Unique ID on distributed systems pic High Level Programming 4 05-10-2006 07:25 AM
Limiting length of user in while creating user Satya Mishra AIX 2 04-14-2005 11:40 PM
Script to count unique number of user loged in elchalateco Shell Programming and Scripting 1 09-30-2002 08:32 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-18-2005
Registered User
 

Join Date: Oct 2005
Posts: 11
creating unique lists from user input

hi all,

I'm trying to resolve a scenario where we prompt the user to enter 1 or more disk names.

From there we would run a command on each disk which would give its location.

This would allow us to create a list of disks at location A, a list of disks at location B,....etc...

Any help on creating these multiple lists?

script would do something like:


Enter disk(s): disk1 disk2 disk3 disk4

# behind the scenes we would run something like
# get_location disk1 (for each disk)
# which returns something like NY, Florida, etc...
# would set up the unique lists here
# then give back to user

Disks disk1 disk2 are at location Florida
Disk disk3 is at location NY
Disk disk4 is at location Boston

Our scenerio is a little more complicated than this but I wanted to get it down to the most basic example I could to make the question easier to ask.

Any suggestion on how to build these unique lists in my shell script?
(sadly we can't use perl here as its cross platform...etc..)

thanks
Annie
Reply With Quote
Forum Sponsor
  #2  
Old 11-19-2005
Registered User
 

Join Date: Jul 2005
Location: Oak Park, IL
Posts: 100
printf "Enter disk list: "
read a
set "$a"
while [ -n "$1" ] ; do
echo Working on $1; shift
(...do whatever work you need to do...)
done

-Mike
P.S. Don't make the user do too much work. They should be able to enter "1", "2", "3", etc. You can do the rest; example...
printf "Enter disk list: "
read a
set "$a"
while [ -n "$1" ] ; do
disk="disk$1"
echo Working on $disk; shift
(...do whatever work you need to do...)
done

Last edited by mschwage; 11-19-2005 at 10:24 PM. Reason: Another thought...
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0