You are not logged in.
I'd like to create a basic calculator script that makes doing calculations a bit easier from the command line. Normally i do:
echo "32*24" | bc
So I built a bash script that I can just type "calc 32*24":
bc << EOF
scale=4
$@
quit
EOF
And it works ok until i try to use parenthesis:
calc (1+49)/5
bash: syntax error near unexpected token `1+49'
if I use parenthesis, directly in the bc command it does ok:
bc
bc 1.06...
(1+49)/5
10
I've tried putting $@ in quotes but not luck. Looks like bash isn't transferring the parenthesis. How can I get the bash script to pass theparenthesis?
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline
you have to quote your expression.
AFAIK, bash expands "(stuff)" in a subshell: this means the problem is not in your script, but in the line you invoke your script with.
Offline
This is why I always have at least one terminal in an IPython session.
Offline
Dang, answer was easier than i thought. Would be nice to be able to have everything in the script but it's easy just to do quotes from the command line. Thanks.
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline
Offline
Whats ipython got to do with my calc script? What planet r u from? I thought they spoke English down there. lol
1+!!
Last edited by Gen2ly (2009-04-12 05:36:07)
Setting Up a Scripting Environment | Proud donor to wikipedia - link
Offline