Discussion:
[BusyBox] If statements.. using ASH
KrutAw at aol.com ()
2003-07-19 13:33:39 UTC
Permalink
I'm currently unable to run an if statement with busybox 0.60.3 compiled with
uclibc.

Here's an example of the if statement I'm trying to run in my bash script:

CMDLINEPARAM=1
if [ $# -ge $CMDLINEPARAM ]
then
NAME=$1
else
NAME="blah"
fi


What am I doing wrong here?

Thanks,

Andy Kruta CNA, A+, Net+
rich_wilson at agilent.com ()
2003-07-19 13:33:39 UTC
Permalink
Try replacing [ ... ] with test.
if test $# -ge $CMDLINEPARAM

Rich

Rich Wilson
Agilent Technologies
425-335-2245
-----Original Message-----
Sent: Tuesday, May 21, 2002 6:02 AM
Subject: [BusyBox] If statements.. using ASH
I'm currently unable to run an if statement with busybox
0.60.3 compiled with
uclibc.
Here's an example of the if statement I'm trying to run in my
CMDLINEPARAM=1
if [ $# -ge $CMDLINEPARAM ]
then
NAME=$1
else
NAME="blah"
fi
What am I doing wrong here?
Thanks,
Andy Kruta CNA, A+, Net+
_______________________________________________
busybox mailing list
http://busybox.net/mailman/listinfo/busybox
Goetz Bock
2003-07-19 13:33:39 UTC
Permalink
Post by rich_wilson at agilent.com ()
Try replacing [ ... ] with test.
if test $# -ge $CMDLINEPARAM
and add a ;

if [ $# -ge $CMDLINEPARAM ]; then
....
fi

but maybe that is only required when you don't have a newline (I'm using
above syntax with 0.60.3 on my initrd/linuxrc scripts)

Cu,
Goetz.
Goetz Bock
2002-05-21 13:57:02 UTC
Permalink
Post by rich_wilson at agilent.com ()
Try replacing [ ... ] with test.
if test $# -ge $CMDLINEPARAM
and add a ;

if [ $# -ge $CMDLINEPARAM ]; then
....
fi

but maybe that is only required when you don't have a newline (I'm using
above syntax with 0.60.3 on my initrd/linuxrc scripts)

Cu,
Goetz.
WILSON,RICH (A-LakeStevens,ex1)
2003-07-19 13:33:39 UTC
Permalink
Are you saying [ ... ] should work with ash?


BusyBox v0.60.3 (2002.05.02-16:43+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

# if [ 2 -eq 3 ]; then
echo hi
fi
[: No such file or directory
# if test 2 -eq 3; then
echo hi
fi
#

Rich


Rich Wilson
Agilent Technologies
425-335-2245
-----Original Message-----
Sent: Tuesday, May 21, 2002 7:56 AM
Subject: Re: [BusyBox] If statements.. using ASH
Post by rich_wilson at agilent.com ()
Try replacing [ ... ] with test.
if test $# -ge $CMDLINEPARAM
and add a ;
if [ $# -ge $CMDLINEPARAM ]; then
....
fi
but maybe that is only required when you don't have a newline
(I'm using
above syntax with 0.60.3 on my initrd/linuxrc scripts)
Cu,
Goetz.
_______________________________________________
busybox mailing list
http://busybox.net/mailman/listinfo/busybox
Goetz Bock
2003-07-19 13:33:39 UTC
Permalink
Post by WILSON,RICH (A-LakeStevens,ex1)
Are you saying [ ... ] should work with ash?
Yes, if you make the required link ln -s /bin/busybox /usr/bin/[

Cu,
Goetz
Goetz Bock
2002-05-21 15:01:03 UTC
Permalink
Post by WILSON,RICH (A-LakeStevens,ex1)
Are you saying [ ... ] should work with ash?
Yes, if you make the required link ln -s /bin/busybox /usr/bin/[

Cu,
Goetz
WILSON,RICH (A-LakeStevens,ex1)
2003-07-19 13:33:39 UTC
Permalink
Thank you! That solves that mystery.
Although I decided to be a rebel and do 'ln /bin/busybox /bin/['

Rich

Rich Wilson
Agilent Technologies
425-335-2245
-----Original Message-----
Sent: Tuesday, May 21, 2002 9:00 AM
Subject: Re: [BusyBox] If statements.. using ASH
Post by WILSON,RICH (A-LakeStevens,ex1)
Are you saying [ ... ] should work with ash?
Yes, if you make the required link ln -s /bin/busybox /usr/bin/[
Cu,
Goetz
_______________________________________________
busybox mailing list
http://busybox.net/mailman/listinfo/busybox
Edmund Troche
2003-07-19 13:33:39 UTC
Permalink
Normally there's a soft link from test to '['. Try "ln -s test", and see if this
fixes your problem.


Edmund Troche
Post by KrutAw at aol.com ()
I'm currently unable to run an if statement with busybox 0.60.3 compiled with
uclibc.
CMDLINEPARAM=1
if [ $# -ge $CMDLINEPARAM ]
then
NAME=$1
else
NAME="blah"
fi
What am I doing wrong here?
Thanks,
Andy Kruta CNA, A+, Net+
_______________________________________________
busybox mailing list
http://busybox.net/mailman/listinfo/busybox
KrutAw
2002-05-21 12:04:05 UTC
Permalink
I'm currently unable to run an if statement with busybox 0.60.3 compiled with
uclibc.

Here's an example of the if statement I'm trying to run in my bash script:

CMDLINEPARAM=1
if [ $# -ge $CMDLINEPARAM ]
then
NAME=$1
else
NAME="blah"
fi


What am I doing wrong here?

Thanks,

Andy Kruta CNA, A+, Net+
rich_wilson
2002-05-21 13:50:04 UTC
Permalink
Try replacing [ ... ] with test.
if test $# -ge $CMDLINEPARAM

Rich

Rich Wilson
Agilent Technologies
425-335-2245
rich_wilson at agilent.com
-----Original Message-----
From: KrutAw at aol.com [mailto:KrutAw at aol.com]
Sent: Tuesday, May 21, 2002 6:02 AM
To: busybox at busybox.net
Subject: [BusyBox] If statements.. using ASH
I'm currently unable to run an if statement with busybox
0.60.3 compiled with
uclibc.
Here's an example of the if statement I'm trying to run in my
CMDLINEPARAM=1
if [ $# -ge $CMDLINEPARAM ]
then
NAME=$1
else
NAME="blah"
fi
What am I doing wrong here?
Thanks,
Andy Kruta CNA, A+, Net+
_______________________________________________
busybox mailing list
busybox at busybox.net
http://busybox.net/mailman/listinfo/busybox
WILSON,RICH (A-LakeStevens,ex1)
2002-05-21 14:27:03 UTC
Permalink
Are you saying [ ... ] should work with ash?


BusyBox v0.60.3 (2002.05.02-16:43+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

# if [ 2 -eq 3 ]; then
echo hi
fi
[: No such file or directory
# if test 2 -eq 3; then
echo hi
fi
#

Rich


Rich Wilson
Agilent Technologies
425-335-2245
rich_wilson at agilent.com
-----Original Message-----
From: Goetz Bock [mailto:bock at blacknet.de]
Sent: Tuesday, May 21, 2002 7:56 AM
To: busybox at busybox.net
Subject: Re: [BusyBox] If statements.. using ASH
Post by rich_wilson at agilent.com ()
Try replacing [ ... ] with test.
if test $# -ge $CMDLINEPARAM
and add a ;
if [ $# -ge $CMDLINEPARAM ]; then
....
fi
but maybe that is only required when you don't have a newline
(I'm using
above syntax with 0.60.3 on my initrd/linuxrc scripts)
Cu,
Goetz.
_______________________________________________
busybox mailing list
busybox at busybox.net
http://busybox.net/mailman/listinfo/busybox
WILSON,RICH (A-LakeStevens,ex1)
2002-05-21 16:56:04 UTC
Permalink
Thank you! That solves that mystery.
Although I decided to be a rebel and do 'ln /bin/busybox /bin/['

Rich

Rich Wilson
Agilent Technologies
425-335-2245
rich_wilson at agilent.com
-----Original Message-----
From: Goetz Bock [mailto:bock at blacknet.de]
Sent: Tuesday, May 21, 2002 9:00 AM
To: busybox at busybox.net
Subject: Re: [BusyBox] If statements.. using ASH
Post by WILSON,RICH (A-LakeStevens,ex1)
Are you saying [ ... ] should work with ash?
Yes, if you make the required link ln -s /bin/busybox /usr/bin/[
Cu,
Goetz
_______________________________________________
busybox mailing list
busybox at busybox.net
http://busybox.net/mailman/listinfo/busybox
Edmund Troche
2002-05-21 18:47:03 UTC
Permalink
Normally there's a soft link from test to '['. Try "ln -s test", and see if this
fixes your problem.


Edmund Troche
Post by KrutAw at aol.com ()
I'm currently unable to run an if statement with busybox 0.60.3 compiled with
uclibc.
CMDLINEPARAM=1
if [ $# -ge $CMDLINEPARAM ]
then
NAME=$1
else
NAME="blah"
fi
What am I doing wrong here?
Thanks,
Andy Kruta CNA, A+, Net+
_______________________________________________
busybox mailing list
busybox at busybox.net
http://busybox.net/mailman/listinfo/busybox
Continue reading on narkive:
Loading...