debian-live-12.1.0-amd64-gnome.iso로 만든 Debian 라이브 환경에서 쉘 스크립트를 실행할 수 없습니다.

debian-live-12.1.0-amd64-gnome.iso로 만든 Debian 라이브 환경에서 쉘 스크립트를 실행할 수 없습니다.

디스크 A에 WinPE와 유사한 리눅스 생방송 환경을 만들고, , rootfs.tar.gz, 가 포함된 bzImageU 디스크 B를 Burning.shPC에 삽입하고 디스크 A를 이용하여 생방송 환경에 들어갔습니다. 그런데 지금은 Burning.sh라이브 환경에서 실행할 수 없는 것을 발견했고 , 오류는 다음과 같습니다.

bash: ./Burning.sh: cannot execute: required file not found.

콘텐츠Burning.sh

#!/usr/bin/bash

######################################################################
#      Author: madship_xk
######################################################################

current_path=$(pwd)
#clear
    

# First, Fdisk

echo "**1************************************************************************"
echo "**2************************************************************************"


foo(){
    #clear
    echo "**3************************************************************************"
    echo "**4************************************************************************"

    ###获取第二个磁盘的信息###
    #fdisk -l | grep Disk | awk '{FS=" "} {print $2}' | sed 's/:/ /g'  > ./tmp.txt
    ls /dev/sda > ./tmp.txt
    hdstr=`awk 'NR==1 {print}' ./tmp.txt`
    echo "hdstr="${hdstr}
    rm ./tmp.txt

    echo "**5************************************************************************"
    echo "**********            1st Command: FDISK                       ***********"
    echo "**********         Plese Follow the Introduction!              ***********"
    echo "**6************************************************************************"

    fdisk ${hdstr} <<EOT 1>/dev/null 2>/dev/null || exit 1
    d
    1
    d
    2
    d
    3
    d
    4
    d

    n
    p
    1

    +2G
    n
    p
    2



    w
EOT

    echo "**7************************************************************************"
    echo "**********            2nd Command: PARTX                       ***********"
    echo "**********       Please Follow the Introduction!               ***********"
    echo "**8************************************************************************"


    partx ${hdstr} 1>/dev/null

    #sleep 1
    ###判断mmcblk0###
    #if [[ ${hdstr} = '/dev/mmcblk0' ]] ; then
    #   echo "emmc exists..."
    #   hdstr=`printf "%sp" ${hdstr}`
    #   b_mmcFlag="1"
    #else
    #   echo "ssd exists..."
    #   b_mmcFlag="0"
    #fi
    #echo ${hdstr}

    sleep 1

    #clear
    echo "**9************************************************************************"
    echo "**********         3rd Command: FORMAT SDB1                    ***********"
    echo "**********       Please Follow the Introduction!               ***********"
    echo "**10************************************************************************"

    hdstr1=`printf "%s1" ${hdstr}`
    echo ${hdstr1}
    sleep 5
    mkfs.ext4 ${hdstr1} 1>/dev/null
    sleep 1

    #clear
    echo "**11************************************************************************"
    echo "**********        4th Command: FORMAT SDB2                     ***********"
    echo "**********       Please Follow the Introduction!               ***********"
    echo "**12************************************************************************"

    hdstr2=`printf "%s2" ${hdstr}`
    echo ${hdstr2}
    sleep 5
    mkfs.ext4 ${hdstr2} 1>/dev/null
    sleep 1


    #clear
    echo " "
    echo "**13************************************************************************"                                                            
    echo "**********         6th Command: MIRROR IMAGE FOR SDB1          ***********"                                       
    echo "**********         Please Follow the Introduction!             ***********"                                                                
    echo "**14************************************************************************"


    mkdir /mnt/boot
    mount ${hdastr1} /mnt/boot 1>/dev/null
    sleep 5
    grub-install --root-directory=/mnt /dev/sda --force

    cat > /mnt/boot/grub/grub.cfg <<EOF 1>/dev/null || exit 1
    #Begin cfg
    set default=0
    set timeout=5

    set root=(hd0,1)

    menuentry "GNU/Linux, Test-6.4.0-rt" {
        linux /bzImage rw root=/dev/sda2
    }
EOF

    cp "${current_path}/bzImage" /mnt/boot

    umount /mnt/boot

    sleep 1

    #clear
    echo "**15************************************************************************"
    echo "**********         7th Command: MIRROR IMAGE FOR SDB2          ***********"                                                                 
    echo "**********          Please Follow the Introduction!            ***********"                                       
    echo "**16************************************************************************"                               


    sleep 2
    mount ${hdstr2} /mnt
    cp "${current_path}/rootfs.tar.gz" /mnt
    cd /mnt
    tar -vxf rootfs.tar.gz
    rm rootfs.tar.gz
    cd ~
    umount /mnt

    sync

    #clear
    echo "**17************************************************************************"
    echo "**********         7th Command: MIRROR IMAGE FOR SDB2          ***********"                                                                 
    echo "**********          Please Follow the Introduction!            ***********"                                       
    echo "**18************************************************************************"                               
}
    
jumpa(){
    echo "Please input \"BURN\" to go to start point"
    read INP
    #echo $INP
    if [[ $INP = 'BURN' ]] ; then
        echo "Going to Start POINT......"
        sleep 2
        echo 
        foo
    else
        echo 
        jumpa
    fi
}

jumpa

답변1

다음을 실행하여 문제를 해결했습니다.dos2unix Burning.sh

관련 정보