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 > 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
Help in error seen in the Bash script ahjiefreak Shell Programming and Scripting 2 01-22-2008 03:38 AM
Bash Script error? JayC89 Shell Programming and Scripting 13 10-04-2007 04:32 PM
Bash while loop problem Kweekwom Shell Programming and Scripting 5 07-23-2007 12:49 AM
loop does not execute in bash script? fedora Shell Programming and Scripting 2 01-16-2007 12:38 PM
Simple bash for loop problem kingdbag Shell Programming and Scripting 4 09-15-2006 01:00 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 06-06-2007
DILEEP410 DILEEP410 is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 148
error in bash script 'if' loop

SEND_MESSAGE=test
echo $SEND_MESSAGE
if [ $SEND_MESSAGE -eq test ]
then
echo `date` > update_dt_ccaps.lst
echo "The file transfer failed" >> update_dt_ccaps.lst
SEND_MESSAGE=false
fi

The above code is showing error in bash shell as :
./test: line 5: [: test: integer expression expected

But it was not showing any error in ksh.I am compelled to use the bash shell itself.

Would anyone please advise.

With Regards
Dileep
  #2 (permalink)  
Old 06-06-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,418
eq operator is for numerix test, you must use = operator :
Code:
SEND_MESSAGE=test
echo $SEND_MESSAGE
if [ $SEND_MESSAGE = test ]
then
   echo `date` > update_dt_ccaps.lst
   echo "The file transfer failed" >> update_dt_ccaps.lst
   SEND_MESSAGE=false
fi
Jean-Pierre.
  #3 (permalink)  
Old 06-06-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
= is used to string comparison
Code:
if [ $SEND_MESSAGE = "test" ]
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:50 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