Re: Some issues in examples/udhcp/simple.script
On Thu, 5 Sep 2019, Rolf Eike Beer wrote: > > Busybox ash: > > # command ip > -sh: command: not found > # ip a > 1: lo: mtu 65536 qdisc noqueue qlen 1000 > link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 You're probably missing: CONFIG_ASH_CMDCMD=y in your .config. Cheers, -- Cristian ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Some issues in examples/udhcp/simple.script
Am Donnerstag, 5. September 2019, 14:57:15 CEST schrieb Denys Vlasenko: > On Wed, Aug 14, 2019 at 9:50 AM Rolf Eike Beer wrote: > > Hi all, > > > > I have discovered some problems with examples/udhcp/simple.script. I know, > > it's an example, and a simplified one. Most people will still just use it > > because it works, so I would like to point out at least some things. > > > > First, it does not really use ip. At least not if "command" does not > > exist. > > "command" is a mandatory shell builtin. > > https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html > > https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html > section "Command Search and Execution" specifically mentions it. > > The reason for this mention is that its function > can not reasonably be implemented as a separate external tool, > since external tools don't know what functions are defined > in current shell's invocation, thus "command FUNCNAME" > won't work. > > Since it's an internal builtin, using it should be a fastest way to test > whether "ip" can be executed, without assuming a path > ("test -x /usr/bin/ip") or forking a possibly external tool > ("which ip"). > > Which shell do you use so that you don't have "command"? Busybox ash: # command ip -sh: command: not found # ip a 1: lo: mtu 65536 qdisc noqueue qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 … > > The difference between both cases is: ifconfig brings up the interface, ip > > with this command does not. So if you are using ip this will just send > > DHCP > > request to a network interface that has link down, which will not get you > > anywhere. > > Yes, this is different. How about: > > echo "Clearing IP addresses on $interface, upping it" > if command -v ip >/dev/null; then > ip addr flush dev $interface > ip link set dev $interface up > else > ifconfig $interface 0.0.0.0 > fi Which is basically what I'm using now, just different order of commands. Thanks, Eike -- Rolf Eike Beer, emlix GmbH, http://www.emlix.com Fon +49 551 30664-0, Fax +49 551 30664-11 Gothaer Platz 3, 37083 Göttingen, Germany Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160 Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055 emlix - smart embedded open source signature.asc Description: This is a digitally signed message part. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: Some issues in examples/udhcp/simple.script
On Wed, Aug 14, 2019 at 9:50 AM Rolf Eike Beer wrote: > Hi all, > > I have discovered some problems with examples/udhcp/simple.script. I know, > it's an example, and a simplified one. Most people will still just use it > because it works, so I would like to point out at least some things. > > First, it does not really use ip. At least not if "command" does not exist. "command" is a mandatory shell builtin. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html section "Command Search and Execution" specifically mentions it. The reason for this mention is that its function can not reasonably be implemented as a separate external tool, since external tools don't know what functions are defined in current shell's invocation, thus "command FUNCNAME" won't work. Since it's an internal builtin, using it should be a fastest way to test whether "ip" can be executed, without assuming a path ("test -x /usr/bin/ip") or forking a possibly external tool ("which ip"). Which shell do you use so that you don't have "command"? > Fair enough, I know I have ip, so I just deleted the checks and the ifconfig > lines. > > This makes it do nothing. As I found out the culprit is this: > > if command -v ip >/dev/null; then > ip addr flush dev $interface > else > ifconfig $interface 0.0.0.0 > fi > > The difference between both cases is: ifconfig brings up the interface, ip > with this command does not. So if you are using ip this will just send DHCP > request to a network interface that has link down, which will not get you > anywhere. Yes, this is different. How about: echo "Clearing IP addresses on $interface, upping it" if command -v ip >/dev/null; then ip addr flush dev $interface ip link set dev $interface up else ifconfig $interface 0.0.0.0 fi ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Some issues in examples/udhcp/simple.script
Hi all, I have discovered some problems with examples/udhcp/simple.script. I know, it's an example, and a simplified one. Most people will still just use it because it works, so I would like to point out at least some things. First, it does not really use ip. At least not if "command" does not exist. Fair enough, I know I have ip, so I just deleted the checks and the ifconfig lines. This makes it do nothing. As I found out the culprit is this: if command -v ip >/dev/null; then ip addr flush dev $interface else ifconfig $interface 0.0.0.0 fi The difference between both cases is: ifconfig brings up the interface, ip with this command does not. So if you are using ip this will just send DHCP request to a network interface that has link down, which will not get you anywhere. Greetings, Eike -- Rolf Eike Beer, emlix GmbH, http://www.emlix.com Fon +49 551 30664-0, Fax +49 551 30664-11 Gothaer Platz 3, 37083 Göttingen, Germany Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160 Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055 emlix - smart embedded open source signature.asc Description: This is a digitally signed message part. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox