Sponsored Content
Top Forums Shell Programming and Scripting [QUESTION] While umatched error Post 302732589 by Ryuinferno on Sunday 18th of November 2012 02:47:26 PM
Old 11-18-2012
[SOLVED] While umatched error

Hi guys...was trying to use while loop and a sentry to prompt user input again if an invalid option was entered...but somehow I got a "while" unmatched error...The code is as below:

Code:
#!/system/bin/sh

finsh=0 
while [ $finish -ne 0 ] 
do 
echo "Please select an option: " 
echo "1. One" echo "2. Two" 
echo "3. Three" 
echo "4. Exit" 
echo -n "Enter your selection: "; read opt 

if [  $opt -eq 1 ]; then 
echo "Please enter your next selection: " 
echo "1. ABC"
echo "2. DEF" 
echo "3. Main Menu" 

subopt=0 
while [ $subopt -lt 1 ] || [ $subopt -gt 3 ] 
do 
echo -n "Enter your selection: "; read subopt 
if [ $subopt -eq 1 ]; then   
  echo "ABC"   
  echo "Hit enter to continue..."   
  read enterKey 
elif [ $subopt -eq 2 ]; then   
  echo "EFG" 
  echo "Hit enter to continue..." 
  read enterKey 
elif [ $subopt -eq 3 ]; then   
  echo "Returning to main menu" 
  echo "Hit enter to continue..." 
  read enterKey
else   
  echo "Invalid option, please try again..." 
fi 
done  

elif [ $opt -eq 2 ]; then 
echo "Two" 
echo "Press enter to continue..." 
read enterKey 

elif [ $opt -eq 3 ]; then 
echo "Three" 
echo "Press enter to continue..." 
read enterKey  

elif [ $opt -eq 4 ]; then 
echo "Bye!" 
finish=1  

else 
echo "Invalid option, please try again" 
fi 
done

exit

Thanks in advance...Smilie

Last edited by Ryuinferno; 11-18-2012 at 11:54 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Error Question

Every night I recieve this message: Verify Report - Broken/missing symbolic links File With Discrepancies : 213 Total Discrepancies : 213 Can anyone explain what this is and how I can resolve it? Thanks, DJ At Work (4 Replies)
Discussion started by: djatwork
4 Replies

2. UNIX for Advanced & Expert Users

Question about error

While attempting to use ftp to retrieve a file from a remote server (running SCO Unix 5.0.2), it eventually returns a timeout error with the following message - netin: connection reset by peer. I can't find any reference to this error. Has anyone encountered it before, or know what causes it? (3 Replies)
Discussion started by: Howeird
3 Replies

3. Shell Programming and Scripting

Question about error reporting

hi all, i've got a script that takes in what a user enters (multiple entries) and then joins them all together and appends this to a file. what i want to happen now is the terminal should display "record saved" if the save to the file is successful, if it isn't just display the standard unix... (2 Replies)
Discussion started by: wazzag
2 Replies

4. Programming

C Question compilation error

What does the following mean: state_field state_abvr = { "AL","ALABAMA", "AK","ALASKA", . . . }; extern state_field state_abvr; issues we I am facing following compilation issue bosdf9d1:root make CC -I/bto/bcs/shared/include -I/bto/sys/BCS/usr/include ... (1 Reply)
Discussion started by: jaganreddy
1 Replies

5. Shell Programming and Scripting

Question on error from script

I used set -n FS.sh to check for syntax errors. No problems. I run the script with set -x and set -v with the following error: find: bad option ; find: path-list predicate-list Reviewing the verbose output everything is read correctly. The files transfer and the script completes. I can't seem... (4 Replies)
Discussion started by: BigSky
4 Replies

6. Filesystems, Disks and Memory

Question - error during boot

I have an HP NetServer LH3 which is exhibiting an error during the boot process. I am getting the following messages, none of which I've seen before 1. WARNING: SCSI adapter: Cannot install intr vecno=12 type=4 IPL=5 Vector 12 is private 2. WARNING: "TEST_UNIT_READY" Command timed 11 seconds... (0 Replies)
Discussion started by: slant-40
0 Replies

7. Programming

Newbie Question.. -> error: syntax error before ';' token

Hello, the following is generating a error at the line "tmprintf(&tmBundle, _TMC("{0}"),Prompt);"... a bit lost as I am diving into this debug... Thank you in advance... int H_YesNo(TMCHAR *Prompt, int DefVal) { TMCHAR YesNo = '\0'; tmprintf(&tmBundle, _TMC("{0}"),Prompt); while... (3 Replies)
Discussion started by: reelflytime
3 Replies

8. UNIX for Dummies Questions & Answers

Question on FTP Error Log

Hello All, Below is the control card or the file which i am using in shell script to mget files from remote machine via FTP. bash-3.00$ cat ftp_ALD_DAC.log open 10.xx.yy.zzz user D00000187 nb8tr4xx2u ascii cd prod/out lcd /Internal_Impact_TT_Input mget ALD*.TXT bye Below is the... (0 Replies)
Discussion started by: Ariean
0 Replies

9. Shell Programming and Scripting

Error redirection question

Hi gurus, I have a question, need some of your inputs... I have a command like this : export LINE_COUNT=`wc -l test.dat | awk '{print $1}'` echo $LINE_COUNT --- > gives me 2 which is fine as the file has 2 lines. This works fine if the file test.dat is present but in case... (3 Replies)
Discussion started by: calredd
3 Replies

10. Shell Programming and Scripting

Question about syntax error

first of all.. sorry about all the question bombing.. im bored atm so im currently playing around with sh scripting hehe s = `expr ls -s Documents | grep Music | awk '{ print $1 }' ` t = `expr $t + $s` it give syntax error s not found t not found lol... any idea why? (7 Replies)
Discussion started by: Nick1097
7 Replies
read(1)                                                            User Commands                                                           read(1)

NAME
read - read a line from standard input SYNOPSIS
/usr/bin/read [-r] var... sh read name... csh set variable = $< ksh read [ -prsu [n]] [ name ? prompt] [name...] DESCRIPTION
/usr/bin/read The read utility will read a single line from standard input. By default, unless the -r option is specified, backslash () acts as an escape character. If standard input is a terminal device and the invoking shell is interactive, read will prompt for a continuation line when: o The shell reads an input line ending with a backslash, unless the -r option is specified. o A here-document is not terminated after a NEWLINE character is entered. The line will be split into fields as in the shell. The first field will be assigned to the first variable var, the second field to the second variable var, and so forth. If there are fewer var operands specified than there are fields, the leftover fields and their interven- ing separators will be assigned to the last var. If there are fewer fields than vars, the remaining vars will be set to empty strings. The setting of variables specified by the var operands will affect the current shell execution environment. If it is called in a subshell or separate utility execution environment, such as one of the following: (read foo) nohup read ... find . -exec read ... ; it will not affect the shell variables in the caller's environment. The standard input must be a text file. sh One line is read from the standard input and, using the internal field separator, IFS (normally space or tab), to delimit word boundaries, the first word is assigned to the first name, the second word to the second name, and so on, with leftover words assigned to the last name. Lines can be continued using ewline. Characters other than NEWLINE can be quoted by preceding them with a backslash. These backslashes are removed before words are assigned to names, and no interpretation is done on the character that follows the backslash. The return code is 0, unless an end-of-file is encountered. csh The notation: set variable = $< loads one line of standard input as the value for variable. (See csh(1)). ksh The shell input mechanism. One line is read and is broken up into fields using the characters in IFS as separators. The escape character, (), is used to remove any special meaning for the next character and for line continuation. In raw mode, -r, the character is not treated specially. The first field is assigned to the first name, the second field to the second name, and so on, with leftover fields assigned to the last name. The -p option causes the input line to be taken from the input pipe of a process spawned by the shell using |&. If the -s flag is present, the input will be saved as a command in the history file. The flag -u can be used to specify a one digit file descriptor unit n to read from. The file descriptor can be opened with the exec special command. The default value of n is 0. If name is omitted, REPLY is used as the default name. The exit status is 0 unless the input file is not open for reading or an end-of-file is encoun- tered. An end-of-file with the -p option causes cleanup for this process so that another can be spawned. If the first argument contains a ?, the remainder of this word is used as a prompt on standard error when the shell is interactive. The exit status is 0 unless an end-of- file is encountered. OPTIONS
The following option is supported: -r Does not treat a backslash character in any special way. Considers each backslash to be part of the input line. OPERANDS
The following operand is supported: var The name of an existing or non-existing shell variable. EXAMPLES
Example 1: An example of the read command The following example for /usr/bin/read prints a file with the first field of each line moved to the end of the line: example% while read -r xx yy do printf "%s %s " "$yy" "$xx" done < input_file ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of read: LANG, LC_ALL, LC_CTYPE, LC_MES- SAGES, and NLSPATH. IFS Determines the internal field separators used to delimit fields. PS2 Provides the prompt string that an interactive shell will write to standard error when a line ending with a backslash is read and the -r option was not specified, or if a here-document is not terminated after a newline character is entered. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 End-of-file was detected or an error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), ksh(1), line(1), set(1), sh(1), attributes(5), environ(5), standards(5) SunOS 5.10 28 Mar 1995 read(1)
All times are GMT -4. The time now is 08:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy