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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
script not working...select utility mobydick Shell Programming and Scripting 6 05-08-2008 06:33 AM
Extracting select queries from script DILEEP410 Shell Programming and Scripting 3 04-10-2008 10:16 AM
Select matches between line number and end of file? Jerrad Shell Programming and Scripting 4 05-24-2006 07:50 AM
awk to select a column from particular line number mab_arif16 Shell Programming and Scripting 4 05-08-2006 05:26 AM
Script to count unique number of user loged in elchalateco Shell Programming and Scripting 1 09-30-2002 11:32 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-11-2009
family_guy family_guy is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 11
script to ask the user to select a number

hi all,

I have 4 scripts which i would need to run
1. BP.sh
2.DB.sh
3.LK.sh
4.TB.sh

I would like write a script which would ask the user to select a number from 1-4 accordingly and run only that script for him/her

I succeeded till reading the user input but not sure how to run that specific file ( lets say if user puts 2, then i need to run ./DB.sh)

echo " Please enter any one of the following values and press Enter"
echo "1 for BP"
echo "2 for DB"
echo "3 for LK"
echo "4 for TB"
echo "Enter value:"
read mInputValue
if ( $minputvalue = 1)
then......

Thanks in advance...
  #2 (permalink)  
Old 03-11-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
Search for menu script.

Regards
  #3 (permalink)  
Old 03-11-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,847
If your shell supports the select construct:

Code:
PS3='choose a script: '

select s in *sh; do
  ./"$s"
  break
done
  #4 (permalink)  
Old 03-11-2009
family_guy family_guy is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 11
cannot execute the input script

1) *sh
choose a script: bp
all_scrt[4]: ./: 0403-006 Execute permission denied.


bp is having 777 permissions to execute
  #5 (permalink)  
Old 03-11-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,847
Could you post the entire script? I'm wondering why the shell does not perform globbing on the *.
You should choose the number 1, 2 and so on:

Code:
% head *sh
==> BP.sh <==
echo $0

==> DB.sh <==
echo $0

==> LK.sh <==
echo $0

==> TB.sh <==
echo $0
% cat s
#! /bin/sh

PS3='choose a script: '

select s in *sh; do
  ./"$s"
  break
done

% ./s
1) BP.sh
2) DB.sh
3) LK.sh
4) TB.sh
choose a script: 1
./BP.sh

You could also change the code like this:

Code:
#! /bin/sh

PS3='choose a script: '

select s in *sh; do
  [ -e "$s" ] && ./"$s"
  break
done
  #6 (permalink)  
Old 03-11-2009
family_guy family_guy is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 11
works

it worx ...thnk you
Closed Thread

Bookmarks

Tags
menu

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 02:09 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