Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsLinux Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 7th, 2011, 08:44 AM
thelakbe thelakbe is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2011
Posts: 6 thelakbe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 19 sec
Reputation Power: 0
Constraint in while loop

Hi,

I have the following code
Code:
USER=`id|sed -n 's/^[^(]*(\([^)]*\)).*/\1/p'`
while :
        do
        tput cup 9  1 ; echo $CL
        tput cup 7  1 ; echo "Proceed with daily clean up operation (Y/N): _ \c"
        tput cup 7 46 ; read _Proceed
        ##
        ## Validate reply
        ##
        _Proceed="$(echo "$_Proceed" | tr "[:lower:]" "[:upper:]")"

        if [ "$_Proceed" != "Y" -a "$_Proceed" != "N" ] ; then
        tput cup 9 1 ; echo " ERROR: Proceed reply ${_Proceed} is invalid\c"

  Pause ; continue

                  ##If yes proceed, follow

                  if [ "$_proceed" = "Y" ]; then
echo $ENTER THE FILE NAME TO MAIL
read F
#/etc/outils_root/admin_root/send_mail_pj.ksh -s "[PHALANGER_FILES/$USER/`uname -n`]" -f $F -d $DESTINATAIRE
fi

  ## If no proceeed, exit routine

  ##

  if [ "$_Proceed" = "N" ] ; then return ; fi


  break

  done

  fi


while executing this i have a error
./mail.sh: syntax error at line 27 : `done' unexpected
i belive some loop issue but i'm unable to trace it please help me on this.

thanks for the help

Regards
Thelak

Reply With Quote
  #2  
Old December 7th, 2011, 09:24 AM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Sep 2001
Location: Shanghai, An tSín
Posts: 6,894 ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level) 
Time spent in forums: 4 Months 2 Weeks 1 Day 22 h 37 m 21 sec
Reputation Power: 3885
What scripting language are you using?

In bash (for example), a "while" loop is terminated with a "done" statement: see here.

Reply With Quote
  #3  
Old December 8th, 2011, 01:39 AM
thelakbe thelakbe is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2011
Posts: 6 thelakbe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 19 sec
Reputation Power: 0
Quote:
Originally Posted by ishnid
What scripting language are you using?

In bash (for example), a "while" loop is terminated with a "done" statement: see here.


Hi
i missed out the whole query sorry for that now i modified
it
it's having the done but its expecting something
Thanks for understanding.

Regards
Thelak

Reply With Quote
  #4  
Old December 8th, 2011, 04:25 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 50 m 50 sec
Reputation Power: 1485
typo

I generally don't put a colon after a while (as far as I am aware it is redundant).

Code:
_Proceed="$(echo "$_Proceed" | tr "[:lower:]" "[:upper:]")"

is probably not doing what you think due to the usage of the quotes, try:
Code:
_Proceed=$(echo "$_Proceed" | tr "[:lower:]" "[:upper:]" | cut -c 1)

which will also, as a benefit, only return the first character, so "no" or "yes", etc., can be used as valid input

If you are using bash, then your echo commands that use \c will need the -e parameter.

But your main issue is that you have mis-placed the loop/conditional terminators. Without the actual code, what you have is:
Code:
while
  if
    if
    fi
  fi
  fi
done
fi
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > Constraint in while loop

Developer Shed Advertisers and Affiliates



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap