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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
For loop in ksh..Please help.. prashant43 Shell Programming and Scripting 4 08-29-2008 08:56 AM
while loop and CPU .. nivea_jmd High Level Programming 1 08-27-2008 10:57 AM
while loop inside while loop panknil Shell Programming and Scripting 0 01-07-2008 12:49 PM
While loop help need bobo UNIX for Dummies Questions & Answers 2 09-18-2006 09:54 PM
how to get the similar function in while loop or for loop trynew Shell Programming and Scripting 3 06-17-2002 12:09 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-10-2009
sh_help sh_help is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 4
help with While loop and CD

I am new to shell scripting. I am using cygwin to run my scripts.
I ran this script from c:\shell

Here is the script i have.

cd //biz/stcurrentbuilds/1_0
f1=`dir`
echo $f1
f2=`dir`
echo $f2
while [$f1=$f2]
Do
f2=`dir`
echo "No new build"
done

When i run i get error
./ st.txt: line 10: syntax error near unexpected token `done'

Can someone please let me know what is wrong with my script?

Thanks,
  #2 (permalink)  
Old 02-10-2009
quirkasaurus's Avatar
quirkasaurus quirkasaurus is offline
Registered User
  
 

Join Date: Jan 2009
Location: canton, michigan
Posts: 373
"Do" shouldn't be capitalized.
  #3 (permalink)  
Old 02-10-2009
sh_help sh_help is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 4
Quote:
Originally Posted by quirkasaurus View Post
"Do" shouldn't be capitalized.
Thanks.

Now i got line 6 command not found error. It seems some thing wrong with expression in while loop. Appreciate if you can please help.
  #4 (permalink)  
Old 02-10-2009
quirkasaurus's Avatar
quirkasaurus quirkasaurus is offline
Registered User
  
 

Join Date: Jan 2009
Location: canton, michigan
Posts: 373
try putting the comparisons within double quotes like so:

while [ "$f1" = "$f2" ]; do
  #5 (permalink)  
Old 02-10-2009
sh_help sh_help is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 4
Quote:
Originally Posted by quirkasaurus View Post
try putting the comparisons within double quotes like so:

while [ "$f1" = "$f2" ]; do
I still get this error.

I the directory i have s.txt and st.txt
both f1 and f2 should have the same value. It seems like comparison failed.

$ ./st.txt
s.txt st.txt
s.txt st.txt
./st.txt: line 6: [s.txt st.txt: command not found
  #6 (permalink)  
Old 02-10-2009
sh_help sh_help is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 4
Quote:
Originally Posted by sh_help View Post
I still get this error.

I the directory i have s.txt and st.txt
both f1 and f2 should have the same value. It seems like comparison failed.

$ ./st.txt
s.txt st.txt
s.txt st.txt
./st.txt: line 6: [s.txt st.txt: command not found

Thanks quirkasaurus
I'm all set.
I wasn't using spaces before and after variable and "=" sing in the comparison.
Thanks agian.
Closed Thread

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0