Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
执行MacOsx脚本时出现问题_Macos_Bash_Shell_Osx Elcapitan - Fatal编程技术网

执行MacOsx脚本时出现问题

执行MacOsx脚本时出现问题,macos,bash,shell,osx-elcapitan,Macos,Bash,Shell,Osx Elcapitan,我需要将ElCapitan.app转换为.Iso映像,以便在windows 10上的VirtualBox上使用它。我在互联网上找到了以下脚本: #!/bin/bash # Mount the installer image  hdiutil attach /Aplicaciones/Instalar\ OS\X\El\Capitan.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mo

我需要将ElCapitan.app转换为.Iso映像,以便在windows 10上的VirtualBox上使用它。我在互联网上找到了以下脚本:

    #!/bin/bash

    # Mount the installer image     
    hdiutil attach /Aplicaciones/Instalar\ OS\X\El\Capitan.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app 

    # Create the ElCapitan Blank ISO Image of 7316mb with a Single Partition -Apple Partition Map
    hdiutil create -o /tmp/ElCapitan.cdr -size 7316m -layout SPUD -fs HFS+J  

    # Mount the ElCapitan Blank ISO Image
    hdiutil attach /tmp/ElCapitan.cdr.dmg -noverify -nobrowse -mountpoint/Volumes/install_build

    # Restore the Base System into the ElCapitan Blank ISO Image 
    asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase  

    # Remove Package link and replace with actual files  
    rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/ 

    # Copy El Capitan installer dependencies  
    cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg

    # Unmount the installer image  
    hdiutil detach /Volumes/install_app  

    # Unmount the ElCapitan ISO Image  
    hdiutil detach /Volumes/OS\ X\ Base\ System/ 

     # Convert the ElCapitan ISO Image to ISO/CD master (Optional)  
     hdiutil convert /tmp/ElCapitan.cdr.dmg -format UDTO -o /tmp/ElCapitan.iso

    # Rename the ElCapitan ISO Image and move it to the desktop  
    mv /tmp/ElCapitan.iso.cdr ~/Desktop/ElCapitan.iso

我还授予了755权限。执行(.txt、.rtf、.command)后,我收到以下错误:

    ./scriptcapitan.rtf: line 1: {rtf1ansiansicpg1252cocoartf1348cocoasubrtf170: command not found
    ./scriptcapitan.rtf: line 2: syntax error near unexpected token `}'
    ./scriptcapitan.rtf: line 2: `{\fonttbl\f0\fnil\fcharset0 Verdana;}'

为什么我会犯这个错误?我必须将其转换为UTF-8吗?

您需要将rtf文档转换为纯文本文档

TextEdit Menu -> Format -> Make Plain Text(Shift-Command-T)
rtf文档具有特殊的格式和文本样式。台词:

./scriptcapitan.rtf: line 1: {rtf1ansiansicpg1252cocoartf1348cocoasubrtf170: command not found
./scriptcapitan.rtf: line 2: syntax error near unexpected token `}'
./scriptcapitan.rtf: line 2: `{\fonttbl\f0\fnil\fcharset0 
Verdana;}'

定义这些参数并将其放在代码上方,您就无法在TextEdit中看到它们。

您需要将脚本保存为纯文本文件,而不是RTF文件。RTF文件包含大量干扰shell解释器的格式化代码。@Albis:chepner是对的!在文本编辑中保存文件时,应更改文件格式。更改扩展名,不要更改文件格式:这是两件不同的事情。谢谢,我终于得到了它!