The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
using ssh with a for loop din Shell Programming and Scripting 4 03-05-2009 03:32 AM
while loop inside while loop panknil Shell Programming and Scripting 0 01-07-2008 12:49 PM
for loop help smtpgeek Shell Programming and Scripting 12 11-09-2005 08:04 PM
while loop whited05 Shell Programming and Scripting 2 11-03-2005 12:27 PM
how to get the similar function in while loop or for loop trynew Shell Programming and Scripting 3 06-17-2002 11:09 AM

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 03-11-2009
ruben.rodrigues ruben.rodrigues is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 45
while loop in /bin/sh

Hi!

I want my script to enter in a while cicle. And I did a:

var=0

while [$var < 1]
do
echo "while"
done

this is very simple because it's just for testing

So what I think that was suppost to happen was
while
while
while
while
while
while
....
....
while

BUT nothing

what is wrong in my while

thanks
  #2 (permalink)  
Old 03-11-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,869
Try changing the < operator:

Code:
while [ "$var" -lt 1 ]
do
  echo "while"
done
  #3 (permalink)  
Old 03-11-2009
ruben.rodrigues ruben.rodrigues is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 45
Quote:
Originally Posted by radoulov View Post
Try changing the < operator:

Code:
while [ "$var" -lt 1 ]
do
  echo "while"
done
thanks, it works but not in my script because it says line 29 [0: not found (????)
so my code is:


Quote:
#!/bin/sh

var=0
echo $var
LOGFILE=`mktemp -t svn_checkout.XXXXXX`
ICONPATH="`dirname $0`/svn.xpm"
list=`ssh ruben@192.168.1.3 "ls /esp-server/svn"`
URL=`zenity --entry --title="Subversion: Checkout" --text="$list

Enter repository folder according to the the aboves:" --entry-text="" --width=400 --window-icon="$ICONPATH" 2>&1`

if [ $? -eq 0 ] ; then
svn checkout svn+ssh://ruben@192.168.1.3/esp-server/svn/$URL &> $LOGFILE & pid1=$!
echo $pid1
zenity --progress --pulsate --auto-kill & pid2=$!
echo $pid2
DIR=/proc/$pid1
echo $DIR
while [$var -lt 1]
do
echo "while"
if [ -d $DIR ] ; then
echo "does exist"
else
echo "does not exist"
fi
done
rm -f $LOGFILE
fi
echo "end"
and my line 29 is the last fi. And I have a lot of echo to show me the status.
Now I realy don't know why it doesn't enter in the while
Can you help me??

thanks
  #4 (permalink)  
Old 03-11-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,869
Change this:

Code:
[$var -lt 1]
to this

Code:
[ $var -lt 1 ]
You need a space after the opening bracket and another one before the closing one.
  #5 (permalink)  
Old 03-11-2009
ruben.rodrigues ruben.rodrigues is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 45
Quote:
Originally Posted by radoulov View Post
Change this:

Code:
[$var -lt 1]
to this

Code:
[ $var -lt 1 ]
You need a space after the opening bracket and another one before the closing one.

MANNNNNN no way. lol I lost sooooo many time and was just a space. lol

thanks
  #6 (permalink)  
Old 03-11-2009
ruben.rodrigues ruben.rodrigues is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 45
other thing
here:
if [ -d $DIR ] ; then

how can I use a not
like -d $DIR but negative
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 08:54 PM.


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