![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| scipt dividing strings /reg expr | maco_home | UNIX for Dummies Questions & Answers | 3 | 08-30-2007 06:39 AM |
| math.h: float ceilf(float x) | jonas.gabriel | High Level Programming | 1 | 06-14-2007 12:20 AM |
| dividing a file into two | jazz | High Level Programming | 2 | 10-20-2006 04:55 AM |
| comparing two float values | kavitha | Shell Programming and Scripting | 2 | 04-02-2004 10:32 PM |
| dividing the screen >>> | ShockTeam | UNIX for Dummies Questions & Answers | 4 | 11-06-2001 05:29 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Dividing float values
Hi
I know its a dumb question but can any one please explain me the difference of executing a shell script in the following 2 ways. . script.sh sh script.sh I have a problem if I execute the following code as sh script.sh DB_CNT_ALW=0.20 SCT_VAR=0.05 if [ "$(echo "if (${DB_CNT_ALW} > ${SCT_VAR}) 1" | bc)" -eq 1 ]; then echo "== Difference is greater" else echo "== Difference is not greater" fi The above mentioned code was suggested by vgersh99. But the same code works well if I execute the script as . script.sh I would prefer executing the script as sh script.sh since if I use exit command inside the script it won't come out of unix but instead exit from the script. Thanks Shash |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
". script.sh" will execute the script in the current environment, as if you had typed all the commands in script.sh at the command prompt. Therefore, an "exit" in the script will exit your session. Why not just chmod +x the script and run it by doing:
Code:
./script.sh |
|
#3
|
||||
|
||||
|
You can't run that script as:
sh script.sh because sh is an ancient shell that cannot run that code. You need to use ksh script.sh bash script.sh or some other reasonably modern shell. |
|
#4
|
|||
|
|||
|
Thanks Glenn Arndt & Perderabo!!
Both the solutions are working. |
|||
| Google The UNIX and Linux Forums |