i remember some scripts that test variables by the following way:
if [ "X$1" == "X" ]
obviously if $1 is null then the statement is true X==X, and if the
variable not null, the statement is false, so
if [ "X$1" == "X" ]
then
echo "arg is null"
else
echo "arg is $1"
fi
will work.
dbrett wro
Thanks to everybody for your help and explainations. I ended up with what
I needed and an explaination of how somethings work. I also have a
direction on where to learn more
thanks again
david
On Wed, 11 Dec 2002, Robert P. J. Day wrote:
> On Wed, 11 Dec 2002, dbrett wrote:
>
> > Now I am rea
On Wed, 11 Dec 2002, dbrett wrote:
> Now I am really confused!
>
> This works:
> #!/bin/bash
>
> if [ -z $1 ]; then
> echo ''
> echo "format is $0 'math equation'"
> echo "i.e. $0 (2+2)*3"
> echo ''
> exit
> fi
>
> echo $1 | /usr/bin/bc -l
assuming that
On Wed, 11 Dec 2002, dbrett wrote:
> Nope, unless I missed what you trying to get at.
>
> #!/bin/bash
>
> if [$1 == '']; then
> echo ''
> echo "format is $0 'math equation'"
> echo "i.e. $0 (2+2)*3"
> echo ''
> exit
> fi
>
> echo $1 | /usr/bin/bc -l 2>&1
; To: Robert P. J. Day
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: minor bash script issue
> >
> >
> > I though your correction would work, but the output still gives me the
> > error message. I would really like to fix it, but will settle for not
> > s
On 11 Dec 2002, Bret Hughes wrote:
> format is ./bc.test.sh 'math equation'
> i.e. ./bc.test.sh (2+2)*3
>
> [bhughes@bretsony bhughes]$ bc.test.sh (2+2)*3
> bash: syntax error near unexpected token `(2+2)'
> [bhughes@bretsony bhughes]$
> [bhughes@bretsony bhughes]$ bc.test.sh '(2+2)*3'
> 12
by
Now I am really confused!
This works:
#!/bin/bash
if [ -z $1 ]; then
echo ''
echo "format is $0 'math equation'"
echo "i.e. $0 (2+2)*3"
echo ''
exit
fi
echo $1 | /usr/bin/bc -l
If you notice the only change I made was go with the better test for a
blank v
> -Original Message-
> From: dbrett [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, December 11, 2002 2:29 PM
> To: Robert P. J. Day
> Cc: [EMAIL PROTECTED]
> Subject: Re: minor bash script issue
>
>
> I though your correction would work, but the output still g
I though your correction would work, but the output still gives me the
error message. I would really like to fix it, but will settle for not
seeing the error.
#!/bin/bash
if [$1 == '']; then
echo ''
echo "format is $0 'math equation'"
echo "i.e. $0 (2+2)*3"
echo
Nope, unless I missed what you trying to get at.
#!/bin/bash
if [$1 == '']; then
echo ''
echo "format is $0 'math equation'"
echo "i.e. $0 (2+2)*3"
echo ''
exit
fi
echo $1 | /usr/bin/bc -l 2>&1 /dev/null
Here is the output
./math "2 + 3 *( 5 - 3 )" <---
On Wed, 2002-12-11 at 12:05, dbrett wrote:
> I have a bash to math calucations. It works but also complains about the
> last line, even though it works.
>
> Any ideas how to fix the problem or at least not see the error message and
> still work.
>
> #!/bin/bash
>
> if [$1 == '']; then
>
On Wed, 11 Dec 2002, Francisco Neira wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> dbrett wrote:
> | I have a bash to math calucations. It works but also complains about the
> | last line, even though it works.
> |
> | Any ideas how to fix the problem or at least not see the error
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
dbrett wrote:
| I have a bash to math calucations. It works but also complains about the
| last line, even though it works.
|
| Any ideas how to fix the problem or at least not see the error message and
| still work.
|
| #!/bin/bash
|
| if [$1 == ''];
13 matches
Mail list logo