[英]Failed to execute bash script on mac
我創建了以下簡單的測試腳本
#!/bin/bash
echo "test"
我使用chmod +x ./msa.sh
來執行它。
現在,當我嘗試像./msa
一樣運行它時,出現以下錯誤,
Failed to execute process ‘./msa.sh'. Reason:
exec: Exec format error
The file './msa.sh' is marked as an executable but could not be run by the operating system.
我將mac
與fish
一起使用,要成功運行該怎么辦?
您確定要將腳本另存為純文本文件嗎? 如果您使用的是TextEdit,則可能正在保存RTF。 選擇“格式”>“生成純文本”,然后根據需要重新保存文件。
您還可以從外殼檢查文件,以確保它以您期望的shebang行開頭。 例如:
nicholas@mary ~> file msa.sh
msa.sh: Rich Text Format data, version 1, ANSI
nicholas@mary ~> head -1 msa.sh
{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf400
那不是你想要的。
nicholas@mary ~> file msa.sh
msa.sh: Bourne-Again shell script, ASCII text executable
nicholas@mary ~> head -1 msa.sh
#!/bin/bash
這就是您想要的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.