简单的脚本带来了无意义的错误

时间:2013-01-15 12:14:48

标签: android linux shell android-emulator

我一直在尝试为android创建一个shell脚本,删除某些文件以稍微强化设备以抵御攻击。这个脚本已经在ubuntu运行froyo的android模拟器上工作了。当我尝试在运行4.2的Windows机器上运行它时会在底部显示错误。我检查了所有目录,它们存在。我正在使用adb运行它。

echo             ANDROID
echo      HARDENING STARTED
#removing files in the /system/xbin directory
mount -o rw,remount /dev/block/mdblock0 /system
    rm  /system/xbin/tcpdump
            rm  /system/xbin/su
#removing files in the /system/bin directory
                    rm  /system/bin/bootanimation
                    rm  /system/bin/dumpstate
                    rm  /system/bin/ping
                    rm  /system/bin/ping6
mount -o ro,remount /dev/block/mdblock0 /system
echo                    ANDROID
echo              HARDENING COMPLETE

带回这个错误..我不知道最新情况。

ANDROID
HARDENING STARTED
mount:No such file or directory
, No such file or directorytcpdump
, No such file or directorysu
, No such file or directoryootanimation
, No such file or directoryumpstate
, No such file or directorying
, No such file or directorying6
mount:No such file or directory
ANDROID
HARDENING COMPLETE

请帮助

赖安

2 个答案:

答案 0 :(得分:2)

目录/system不存在,因此您的mount命令失败。

接下来,您尝试从不存在的/system目录中删除几个文件,这会导致更多错误。

最后,您尝试重新安装仍然不存在的/system,从而导致您的上一次错误。

唯一的问题是错误消息有点乱码,文件名被消息以某种方式覆盖。

修改:要回答您的其他问题......

如果你能check if the file exists,你可以正确处理这种情况(而不是使用通配符):

# Check which device to use
if [ -e /dev/block/mdblock0 ]; then
  device=/dev/block/mdblock0
elif [ -e /dev/block/mtdblock0 ]; then
  device=/dev/block/mtdblock0
else
  echo "Device not found";
  exit 1;
fi

mount -o rw,remount $device /system
# etc...

我不知道确切的Android shell命令,但假设它与bash非常相似,这应该可行。

答案 1 :(得分:1)

将结尾的行更改为Unix样式,将解决您的所有问题。

相关问题