The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
A basic question of FOR loop er_ashu UNIX for Dummies Questions & Answers 3 09-28-2007 10:41 AM
oracle and loop question pavan_test UNIX for Dummies Questions & Answers 4 09-28-2006 11:23 PM
Simple while loop question Brokeback Shell Programming and Scripting 3 07-21-2006 09:04 AM
foreach loop question clipski UNIX for Dummies Questions & Answers 7 12-22-2005 01:28 PM
Loop question strike Shell Programming and Scripting 18 04-13-2005 10:24 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-01-2007
stepnkev stepnkev is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 7
while loop question

while [ $dev_num ]
do
print What is the next device number to be added to $dgroup?
print Press \<Enter\> if there are no more devices to be added.
read dev_num
export dev_num
symld -g $dgroup -sid $sname add dev $dev_num
done

In this while loop, how do I stop it from running the final command if <Enter> is pressed? Currently, if a user presses <enter> it will still run
symld -g $dgroup -sid $sname add dev
I’m not sure how to skip this command if a user just presses <Enter>

Thanks

Edit: Forgot to mention this is the ksh
  #2 (permalink)  
Old 06-01-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
Here is one way of doing:
Code:
while true
do
  print What is the next device number to be added to $dgroup? 
  print Press \<Enter\> if there are no more devices to be added.
  read dev_num
  if [ "${dev_num}" = "" ]; then
    exit
  fi
  export dev_num
  symld -g $dgroup -sid $sname add dev $dev_num
done
  #3 (permalink)  
Old 06-01-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
Quote:
Originally Posted by Shell_Life
Here is one way of doing:
Code:
while true
do
  print What is the next device number to be added to $dgroup? 
  print Press \<Enter\> if there are no more devices to be added.
  read dev_num
  if [ "${dev_num}" = "" ]; then
    exit
  fi
  export dev_num
  symld -g $dgroup -sid $sname add dev $dev_num
done
exit != break
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0