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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
comparing 2 strings satish@123 Shell Programming and Scripting 2 05-16-2008 04:59 AM
comparing strings agarwal Shell Programming and Scripting 3 04-16-2008 02:29 AM
Urgent:Comparing two Strings using If Loop Anji Shell Programming and Scripting 2 01-09-2008 05:54 AM
Comparing strings yakyaj UNIX for Advanced & Expert Users 2 03-22-2007 10:22 PM
comparing two strings ragha81 Shell Programming and Scripting 24 09-21-2006 08:52 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-09-2008
Registered User
 

Join Date: Jan 2008
Posts: 21
Comparing Two Strings

Hi All,
While I am trying to run below code I Am getting the exception like

./abs.sh: line 102: syntax error near unexpected token `then'
./abs.sh: line 102: ` then'


The Code Snippet is:

if[ "$file1" = "Sector.sql" || "$file1" = "Currency.sql" ] then
cat $file1 | sed -e "s/DB_NAME/${DBNAME}/g" > $LOG_DIR/$file1
$ISQL -U$USER -P$PASSWD -S$SERVERNAME < $LOG_DIR/$file1
echo "$LOG_DIR/$file1 file::::::::"
rm $LOG_DIR/$file
else
. $file1
fi

Can Anybody help me out to rectify that exception.

Thanks,
Anji
Reply With Quote
Forum Sponsor
  #2  
Old 01-09-2008
Registered User
 

Join Date: Nov 2007
Posts: 85
syntax problem

either u should give
if[ "$file1" = "Sector.sql" || "$file1" = "Currency.sql" ]; then
or
if[ "$file1" = "Sector.sql" || "$file1" = "Currency.sql" ]
then
Reply With Quote
  #3  
Old 01-09-2008
Registered User
 

Join Date: Jan 2008
Posts: 21
Thank buddy,
I have tried that logic too...

but still I am getting the following Exception

Code Snippet:
if["$file1" = "Sector.sql" || "$file1" = "Currency.sql"]; then
cat $file1 | sed -e "s/DB_NAME/${DBNAME}/g" > $LOG_DIR/$file1
$ISQL -U$USER -P$PASSWD -S$SERVERNAME < $LOG_DIR/$file1
echo "$LOG_DIR/$file1 file::::::::"
rm $LOG_DIR/$file
else
. $file1
fi

Exception:

./abs.sh: line 101: syntax error near unexpected token `then'
./abs.sh: line 101: ` if["$file1" = "Sector.sql" || "$file1" = "Currency.sql"]; then '
Reply With Quote
  #4  
Old 01-09-2008
Registered User
 

Join Date: Nov 2007
Posts: 85
missing spaces and use -o for OR

if [ "$file1" = "Sector.sql" -o "$file1" = "Currency.sql" ]; then
Reply With Quote
  #5  
Old 01-09-2008
Registered User
 

Join Date: Jan 2008
Posts: 21
Hi,
Thanks for your reply...
Sorry to say that
I have tried with the command which you have given.
but also I am getting the same error....

Code:
if[ "$file1" = "Sector.sql" -o "$file1" = "Currency.sql"]; then
cat $file1 | sed -e "s/DB_NAME/${DBNAME}/g" > $LOG_DIR/$file1
$ISQL -U$USER -P$PASSWD -S$SERVERNAME < $LOG_DIR/$file1
echo "$LOG_DIR/$file1 file::::::::"
rm $LOG_DIR/$file

else
. $file1
fi

Error:
./BatchJobs.sh: line 101: syntax error near unexpected token `then'
./BatchJobs.sh: line 101: ` if[ "$file1" = "Sector.sql" -o "$file1" = "Currency.sql"]; then'



Can u help me out plz....

---Anji
Reply With Quote
  #6  
Old 01-09-2008
Registered User
 

Join Date: Nov 2007
Posts: 85
Its not the same code one space is missing

if[ "$file1" = "Sector.sql" -o "$file1" = "Currency.sql"]; then

if[ "$file1" = "Sector.sql" -o "$file1" = "Currency.sql" ]; then
Reply With Quote
  #7  
Old 01-09-2008
Registered User
 

Join Date: Jan 2008
Posts: 21
I have given the space too

but I am getting the same error as above.....

This silly mistake making me lot of trouble

Can you plz help me out..........

thanks
anji
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:18 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0