![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| for loop not working - syntax error at line 6: `end of file' unexpected | debojyoty | Shell Programming and Scripting | 3 | 04-13-2009 10:31 AM |
| line 3: syntax error near unexpected token `(' | camzio | UNIX Desktop for Dummies Questions & Answers | 4 | 09-29-2008 11:10 AM |
| "syntax error near unexpected token `fi' " | GIC1986 | SUN Solaris | 4 | 09-19-2008 01:17 PM |
| awk Shell Script error : "Syntax Error : `Split' unexpected | Herry | UNIX for Dummies Questions & Answers | 2 | 03-17-2008 11:16 AM |
| syntax error near unexpected token...what caused? | joshuaduan | Shell Programming and Scripting | 8 | 05-14-2007 10:02 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 03:58 PM.. |
|
|||||
|
you have embedded 'case'-s, but only one 'esac'.
Also next time use BB Codes when posting data/code samples - you'll increase the chances of your posts being answered - this is absolutely impossible to read/comprehend. You have posted a part of a script from 'vi' and then the execution. This is impossible to read. Post the entire script using BB Codes in one block AND then output you're getting. Maybe some good Samaritan will try to help you. Good luck. Last edited by vgersh99; 03-25-2009 at 04:14 PM.. |
|
||||
|
Hi all,
I have a similar problem. My script is like: #!/bin/sh FILENAME=$1 while read line do if [[$line = *sometext*]] then echo $line fi done < $FILENAME And I get the error: line 5: syntax error near unexpected token `done' line 5: `done < $FILENAME Would you please share any ideas about how to solve the problem? |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|