Forum

Yampiz Forum

Sharing let knowledge Spreaded, Reading let spirits growth, Creative let culture extended, Let us
  • 禁止廣告文
  • 知識傳播
  • 閱讀
  • 心靈成長
  • 創作
  • 文化傳承
Forum Dictionary / PC / Linux 討論版 /

指令腳本錯誤 bin/bash: bad interpreter

New Subject
Random
Previous
Next
|
指令腳本錯誤 bin/bash: bad interpreter

指令腳本出現 bin/bash: bad interpreter: No such file or directory

錯誤原因之一很有可能是你的腳本文件是DOS格式的, 即每一行的行尾以/r/n來標識, 其ASCII碼分別是0x0D, 0x0A.
可以有很多種辦法看這個文件是DOS格式的還是UNIX格式的, 還是MAC格式的

(1). vi filename
然後用命令
:set ff?
可以看到dos或unix的字樣. 如果的確是dos格式的, 那麼你可以用set ff=unix把它強制為unix格式的, 然後存盤退出. 再運行一遍看.

(2). 用joe filename
如果是DOS格式的, 那麼行尾會有很多綠色的^M字樣出現. 你也可以用上述辦法把它轉為UNIX格式的.

(3). 用od -t x1 filename
如果你看到有0d 0a 這樣的字符, 那麼它是dos格式的, 如果只有0a而沒有0d, 那麼它是UNIX格式的, 同樣可以用上述方法把它轉為UNIX格式的.

轉換不同平台的文本文件格式可以用

1. unix2dos或dos2unix這兩個小程序來做. 很簡單. 在djgpp中這兩個程序的名字叫dtou和utod, u代表unix, d代表dos

2. 也可以用sed 這樣的工具來做:
sed 's/^M//' filename > tmp_filename
mv -f tmp_filename filename
來做

特別說明:^M並不是按鍵shift + 6產生的^和字母M, 它是一個字符, 其ASCII是0x0D, 生成它的辦法是先按CTRL+V, 然後再回車(或CTRL+M)

另外, 當SHELL程序報告command not found時, 總是去檢查一下你的PATH裏面有沒有程序要用到的每一個命令(沒指定絕對路徑的那種). 你這麼小的程序, 可以一行一行核對.

  • This is a reposted article.
  • Keywords : filename, DOS格式, 程序, 字符, 可以, tmp_filename, dos格式, UNIX格式, 錯誤原因, 這麼小, 辦法, 轉換不同平, 路徑, 行尾會, 行尾以, 腳本文件, 簡單, 程序要用到, 用命令, 用od
0 0
2012-05-10T17:13:00+0000


  • Now, you can post comments by Facebook Account when your Yampiz account was logout or unvariable. whatever, we suggest to post comment by Yampiz Account to get more bounds to join new events of Heyxu
Comment
 
Verify

Facebook Page

QR-Code and APP Launcher

User Guide
This Webpage

In those service tabs, "Scan QRCode, in mobile device" or "Click the button, in this device" to open webpage or APP-related operations.
QRCode
  • Auto Platform
    For better browsing experience, it will auto detects your device to display webpage.
  • Bug Report
    Tell us about the idea, problem and errors you found.
  • Comodo Secure
    The sensitive data transmission adopts by SSL-2048 authenticated encryption.
  • Copyright
    © 2009 YamPiz Digital Inc. & Jaby Group. All rights reserved.
  • Revised Version
    V2.2.061
    03 Aug 2023 (GMT+8)