【发布时间】:2013-04-26 05:11:39
【问题描述】:
我正在编写一个可以在我的本地 /bin/sh 上运行的 shell 脚本(Ubuntu 13.04 上的破折号),但我最终需要在一个由于对变量的操作而出现错误的哑盒上运行它:
$((n2 - n1 + 1))
不起作用,我收到如下错误:
syntax error: you disabled math support for $((arith)) syntax
我对那里的sh 不太了解,但我认为这个东西是busybox。我怎么能在这个笨壳上做数学?
编辑小程序列表
~ # busybox --list
[
arp
ash
cat
chgrp
chmod
chown
chroot
chvt
clear
cmp
cp
cut
date
dd
deallocvt
df
dmesg
du
echo
env
false
find
freeramdisk
ftpget
ftpput
grep
gunzip
gzip
hexdump
hwclock
ifconfig
ln
losetup
ls
md5sum
mkdir
mkfifo
mknod
mkswap
more
mount
mv
nslookup
ping
ping6
ps
pwd
renice
reset
rm
rmdir
route
seq
sh
sha1sum
sha256sum
sleep
sort
swapoff
swapon
switch_root
sync
tar
taskset
tee
telnet
test
tftp
time
top
touch
true
umount
uname
uniq
uptime
usleep
vconfig
vi
wget
whoami
yes
【问题讨论】:
-
是的,它是busybox。由于您的
ash如此精简,我猜您的busybox也没有awk小程序?还是外部bc? -
没有
find / -name awk或find / -name bc的结果 -
expr也许?如果没有符号链接,您可能还需要检查$ busybox awk和$ busybox expr。 -
是的,我也试过
expr,不好... -
你的busybox二进制文件来自哪里。一些技巧可能是可能的,但取决于一些busybox小程序或其他,因此了解二进制文件的确切配置将有很大帮助。它会给人们一些可以玩弄的东西。如果无法提供链接,
busybox --list至少会给出可用小程序的列表。
标签: shell math busybox dash-shell