The UNIX and Linux Forums  

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
awk Shell Script error : "Syntax Error : `Split' unexpected Herry UNIX for Dummies Questions & Answers 2 03-17-2008 08:16 AM
syntax error ibroxy Shell Programming and Scripting 5 01-03-2008 05:03 AM
I got error like...syntax error on line 1, teletype koti_rama UNIX for Advanced & Expert Users 2 07-07-2007 04:35 PM
awk syntax error yongho Shell Programming and Scripting 4 06-20-2005 07:03 AM
Syntax error.. livetaurean19 Shell Programming and Scripting 0 06-14-2005 01:23 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 04-07-2008
Registered User
 

Join Date: Apr 2008
Posts: 5
multiplication shows syntax error

my shell script is simple arithmetic process.my addtion,substract and divide all can be worked only except multiplication.please help me.the shell is following:
Code:
#!/usr/bin/sh
echo "enter a number1:"
read number1
echo "enter an operator:"
read operator
echo "enter a number2:"
read number2
echo "result is:"
result='expr $number1 $operator $number2'
echo $result

Last edited by Yogesh Sawant; 04-08-2008 at 01:57 AM. Reason: added code tags
Reply With Quote
Forum Sponsor
  #2  
Old 04-07-2008
vbe vbe is offline
Moderator
 

Join Date: Sep 2005
Location: Switzerland
Posts: 748
What does * represent for the shell?

That should help you see what is going wrong...
Reply With Quote
  #3  
Old 04-07-2008
vbe vbe is offline
Moderator
 

Join Date: Sep 2005
Location: Switzerland
Posts: 748
Since you have posted very lately a few, that give me the feeling its close to homework if not...
I will just show you that modifying just a little your script I end with:
Code:
ra:/home/vbe $ calcul   
enter a number1:
34
enter an operator:
*
enter a number2:
2
result is:
68
ra:/home/vbe $
Look at my previous post and think hard...

Last edited by Yogesh Sawant; 04-08-2008 at 01:58 AM. Reason: added code tags
Reply With Quote
  #4  
Old 08-07-2008
Registered User
 

Join Date: Jul 2008
Posts: 13
I get the strings concatenated if i use below:

temp=23
expr $temp*60

it gives me '23*60' as output instead of the actual multiplied value.
Could you please help me out?
Reply With Quote
  #5  
Old 08-07-2008
Registered User
 

Join Date: Jul 2008
Posts: 13
I got it now. Thanks anyways..

it must be expr[space]$variable[space]\*[space]60

thanks
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:50 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