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
Variables bobo UNIX for Dummies Questions & Answers 1 01-18-2007 09:37 PM
doing a sed on certain variables seaten UNIX for Dummies Questions & Answers 10 09-05-2005 07:45 PM
doing a sed with variables seaten Shell Programming and Scripting 1 05-06-2005 12:08 PM
doing a sed with variables seaten UNIX for Dummies Questions & Answers 1 05-06-2005 11:48 AM
Using Variables to Set Other Variables superdelic UNIX for Dummies Questions & Answers 3 04-21-2005 07:44 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-03-2008
Registered User
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 98
Stumble this Post!
Regarding PS1,PS2,PS3,PS4 variables.

Hello frnds...

I m asking a general question... thought I never faced and used this (PS3) variable... or may be i m not aware of this...

I know very well about the unix prompt string variables PS1,PS2,PS4.

but please tell me what is the use of PS3 and where it's used.
I didnt find anything satisfactory thing by googling...

thanks,,
Anchal.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-03-2008
Registered User
 

Join Date: Nov 2005
Posts: 21
Stumble this Post!
PS3->Prompt string in select loops
Reply With Quote
  #3 (permalink)  
Old 02-03-2008
Registered User
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 98
Stumble this Post!
thanks pt14 for replying..
but the same thing i got on the net... isnt clear for me...

can u please explain this.... preferably by example... that actually whre PS3 come into the picture...

thanks again...
Reply With Quote
  #4 (permalink)  
Old 02-04-2008
rikxik's Avatar
Registered User
 

Join Date: Dec 2007
Posts: 104
Stumble this Post!
Run this to find out:

Code:
#!/bin/ksh

quitstr=Exit
choices="a b c d $quitstr"
PS3="Enter your choice: "
select opt in $choices ; do
        [ "${opt}" = "${quitstr}" ] && break
        [ "x${opt}" = "x" ] && continue
        echo "You chose : $opt"
done
HTH
Reply With Quote
  #5 (permalink)  
Old 02-04-2008
Registered User
 

Join Date: Jun 2007
Location: Mumbai,India
Posts: 98
Stumble this Post!
very thanks rikxik.. got it.
Reply With Quote
  #6 (permalink)  
Old 02-04-2008
Registered User
 

Join Date: Nov 2005
Posts: 21
Stumble this Post!
Consider the script:
select i in jan feb mar exit
do
case $i in
jan) echo "Jan";;
feb) echo "feb";;
mar) echo "mar";;
exit) exit;;
*) echo "invalid entry";;
esac
done

Run the script when you have not set PS3:
1) jan
2) feb
3) mar
1
Jan


When you have set PS3
PS3="Select a month: "
1) jan
2) feb
3) mar
Select the item number: 1
Jan


Hope this helps
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:35 AM.


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

Content Relevant URLs by vBSEO 3.2.0