|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Solaris The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
I have a sh script which contains the following line TOTAL=$((e4-s4)) -> Where e4 and s4 are input got from the user. At the time of execution of this line the following error occurs test.sh: syntax error at line 8: `TOTAL=$' unexpected How to solve this issue?. Can any one help me please?......................... Regards Revathi |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
We need to see the rest of the script to tell why that statement was unexpected.
|
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
I don't know the $((...)) syntax, but it could be from a more exotice shell and not recognised by the Bourne shell.
This should work (for integer arithmetic): let total=e4-s4 |
|
#4
|
||||
|
||||
|
The following is more portable:
TOTAL=`expr $e4 - $s4` From the syntax $((expression)) it looks like your script was probably written to take advantage of specific features in the bash shell. As a result your shell script will not be very portable to non-Linux/GNU systems unless bash is available on these systems. Last edited by fpmurphy; 11-24-2007 at 04:02 PM.. |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Quote:
Below is my script #!/bin/bash echo "Enter the start IP" IFS="." read s1 s2 s3 s4 echo "Enter the End IP" IFS="." read e1 e2 e3 e4 TOTAL=$(($e4 - $s4)) echo "Total is $TOTAL" Any idea |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Quote:
Below is my script #!/bin/bash echo "Enter the start IP" IFS="." read s1 s2 s3 s4 echo "Enter the End IP" IFS="." read e1 e2 e3 e4 TOTAL=$(($e4 - $s4)) echo "Total is $TOTAL" Any idea |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Quote:
You suggestion does not work. Below is my script #!/bin/bash echo "Enter the start IP" IFS="." read s1 s2 s3 s4 echo "Enter the End IP" IFS="." read e1 e2 e3 e4 TOTAL=$(($e4 - $s4)) echo "Total is $TOTAL" Any idea |
| Sponsored Links | ||
|
![]() |
| Tags |
| linux |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| addition of two numbers | lookinginfo | Shell Programming and Scripting | 1 | 10-05-2011 04:38 PM |
| Help with addition of 2 numbers that are read from a file | marmik1903 | Shell Programming and Scripting | 1 | 08-30-2010 12:13 PM |
| Addition of floating numbers | dear_abhi2007 | Shell Programming and Scripting | 4 | 11-17-2009 05:09 AM |
| Addition of all the numbers in a single file | chinni-script | Shell Programming and Scripting | 5 | 04-05-2009 08:46 AM |
| Addition of numbers in unix | asinha63 | Shell Programming and Scripting | 3 | 03-14-2006 11:38 AM |
|
|