Sponsored Content
Top Forums Shell Programming and Scripting While loop error: Unexpected token done Post 302301026 by warlock129 on Wednesday 25th of March 2009 03:50:43 PM
Old 03-25-2009
While loop error: Unexpected token done

I have tried to implement a while loop into the code but upon running the following code i am getting the errors:

./Assigntest: line 42: syntax error near unexpected token `done'
./Assigntest: line 42: `done'



The code is as follows:

Code:
#!/bin/bash
#Filename: Assignment Author: Luke Francis
quit=n
while [ "$quit" = "n" ]
do
clear
echo "OPERATOR ADMINISTRATIVE TOOL"
echo "Please enter your password:"
read password
if [ $password -eq 0600519 ]
then
clear
echo "1. User Information"
echo "2. Network Connectivity"
echo "3. Processes"
echo "4. System Information"
echo "5. Hardware Utilization"
echo "Which option do you require?"
read menunumber
case $menunumber in
1) echo "USER INFORMATION"
echo "1. Registered Users"
echo "2. Disk Usage"
echo "3. Last Logins"
echo "Q.Quit"
echo "Which option do you require?"
read menunumber2
case $menunumber2 in
1) awk -F: '{print $1}' /etc/passwd
echo "Hit the Enter Key to continue"
read junk;;
2) du
echo "Hit Enter Key to continue"
read junk;;
3) who
echo "Hit Enter Key to continue"
read junk;;
Q|q) quit=y;;
*) echo "INCORRECT PASSWORD"
"Assigntest" 43L, 925C written                                
lf1ect@star-gateway$ <0> ./Assigntest
./Assigntest: line 42: syntax error near unexpected token `done'
./Assigntest: line 42: `done'
lf1ect@star-gateway$ <2> vi Assigntest
read password
if [ $password -eq 0600519 ]
then
clear
echo "1. User Information"
echo "2. Network Connectivity"
echo "3. Processes"
echo "4. System Information"
echo "5. Hardware Utilization"
echo "Which option do you require?"
read menunumber
case $menunumber in
1) echo "USER INFORMATION"
echo "1. Registered Users"
echo "2. Disk Usage"
echo "3. Last Logins"
echo "Q.Quit"
echo "Which option do you require?"
read menunumber2
case $menunumber2 in
1) awk -F: '{print $1}' /etc/passwd
echo "Hit the Enter Key to continue"
read junk;;
2) du
echo "Hit Enter Key to continue"
read junk;;
3) who
echo "Hit Enter Key to continue"
read junk;;
Q|q) quit=y;;
*) echo "INCORRECT PASSWORD"
sleep 1
esac
done
echo "Thank you for using the Operator Administrative Tool."

To me the done statement looks to be correct but obviuosly there is something wrong i'd be grateful for some help.

Last edited by vgersh99; 03-25-2009 at 04:58 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Syntax error near unexpected token `('

Guys , This is an output of my script errored out for "Syntax error near unexpected token `(' " Can someone tell me whats wrong with my script. Below is my original script pasted. #!/bin/bash Script Creation Date 01/21/2010 Author baraghun ... (7 Replies)
Discussion started by: raghunsi
7 Replies

2. Shell Programming and Scripting

Syntax error near unexpected token `done'

Hi all, Here is a simple script that is working in one server and is giving a syntax error in other server. Can somebody help me ? #!/bin/bash # ftp files done < $file errors: I tried..with no success: if ; then (21 Replies)
Discussion started by: Lenora2009
21 Replies

3. Shell Programming and Scripting

Unexpected Token Error `;;'

Hello all, Im having an Issue with my script for switch statement , can someone let me know where do i need to correct it. 7 ##******************************************************************************************************* 8 ## ********** FUNCTION USAGE *********** ... (13 Replies)
Discussion started by: raghunsi
13 Replies

4. UNIX for Dummies Questions & Answers

Syntax error near unexpected token

hi! just want to seek help on this error: syntax error near unexpected token 'do this is my script # !/bin/sh # for y in 27 25 do exemmlmx -c "ZEEI;" -n XRT$y >> blah done what can be wrong? thanks! (6 Replies)
Discussion started by: engr.jay
6 Replies

5. Shell Programming and Scripting

syntax error near unexpected token `='

Hi all, This is a script which converts hex to bin. However am finding an error while executing syntax error near unexpected token `=' `($hexfile, $binfile) = @ARGV;' I am running using ./fil.pl <hexfile> <binfile> ################################################### # # this script... (3 Replies)
Discussion started by: jaango123
3 Replies

6. Shell Programming and Scripting

Syntax error near unexpected token `('

What do I do here? #!/bin/bash payload=-1 AND 1=IF(21,BENCHMARK(5000000,MD5(CHAR(115,113,108,109,97,112))),0)# hash=`echo -n $payload md5sum tr -d 'n' sed 'ss-sg' md5sum tr -d 'n' sed 'ss-sg'` curl --data cs2=chronopay&cs1=$payload&cs3=$hash&transaction_type=rebill... (2 Replies)
Discussion started by: iiiiiiiiiii
2 Replies

7. Shell Programming and Scripting

Syntax error near unexpected token `else'

Hi, I am trying to read the session log through script. But it keeps showing me some error near. I have tried everything. Even tried converting the script using sed command to remove the hidden characters(\r).But nothing seems to be working.Below is the script : #!/bin/bash cd... (6 Replies)
Discussion started by: Aryan12345
6 Replies

8. Shell Programming and Scripting

For loop - unexpected token `do

My requirement is to search for current date-1 .log files in /usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs folder and write the file name to filenames.txt When I ran the script below, I got error as syntax error near unexpected token `do I'm not sure what is wrong in my code. I... (11 Replies)
Discussion started by: Ram Kumar_BE
11 Replies

9. Shell Programming and Scripting

Syntax error near unexpected token `else'

Hello every one!! I don't know where I am going wrong but I am finding it difficult to clear this error of syntax error near unexpected token `else' I am writing a simple shell script to find a file in a directory and if found execute that else return an error to the log file ... (14 Replies)
Discussion started by: masubram
14 Replies

10. UNIX for Beginners Questions & Answers

Syntax error near unexpected token 'do'

Hello all, Please i have this command i used to zip different files in differents directory, but i have an error. Note that when i run the command in one directory it works fine. /X5/WORK/BGH/INV/REG/pdf/SEND/BGH12523/1/*.fo /X5/WORK/BGH/INV/REG/pdf/SEND/BGH24523/1/*.fo... (3 Replies)
Discussion started by: gillesi
3 Replies
SHTOOL-ECHO.TMP(1)					      GNU Portable Shell Tool						SHTOOL-ECHO.TMP(1)

NAME
shtool-echo - GNU shtool echo(1) extensional command SYNOPSIS
shtool echo [-n|--newline] [-e|--expand] string DESCRIPTION
shtool echo is an echo(1) style command which prints string to stdout and optionally provides special expansion constructs (terminal bold mode, environment details, date, etc) and newline control. The trick of this command is that it provides a portable -n option and hides the gory details needed to find out the environment details under option -e. OPTIONS
The following command line options are available. -n, --newline By default, output is written to stdout followed by a "newline" (ASCII character 0x0a). If option -n is used, this newline character is omitted. -e, --expand If option -e is used, string can contain special "%x" constructs which are expanded before the output is written. Currently the following constructs are recognized: %B switch terminal mode to bold display mode. %b switch terminal mode back to normal display mode. %u the current user name. %U the current user id (numerical). %g the current group name. %G the current group id (numerical). %h the current hostname (without any domain extension). %d the current domain name. %D the current day of the month. %M the current month (numerical). %m the current month name. %Y the current year. EXAMPLE
# shell script shtool echo -n -e "Enter your name [%B%u%b]: "; read name shtool echo -e "Your Email address might be %u@%h%d" shtool echo -e "The current date is %D-%m-%Y" HISTORY
The GNU shtool echo command was originally written by Ralf S. Engelschall <rse@engelschall.com> in 1998 for Website META Language (WML) under the name buildinfo. It was later taken over into GNU shtool. SEE ALSO
shtool(1), echo(1). 18-Jul-2008 shtool 2.0.8 SHTOOL-ECHO.TMP(1)
All times are GMT -4. The time now is 11:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy