line 10:syntax error: unexpected end of file
在Linux執行如下指令碼的時候:
遇到如下錯誤:
line 10:syntax error: unexpected end of file
多方測試始終不見效果,最終同事陳大師找到了原因,我的指令碼是從Windows上ftp到Linux上的,Linux下的檔案結束符和Windows下的檔案結束符不一樣。在Windows上編輯的指令碼,放在Linux額上執行就會有這種問題。
網上又查了以下,解決方法是使用vim開啟指令碼,執行命令:
set fileformat=unix
儲存退出,再次執行就沒有問題了。當然,也可以在Linux上重新新建一個指令碼。
點選(此處)摺疊或開啟
- #/bin/bash
- echo "You are logged in as `whoami`"
- if [ `whoami` != root ]; then
- echo "Must be logged on as root to run this script."
- fi
line 10:syntax error: unexpected end of file
多方測試始終不見效果,最終同事陳大師找到了原因,我的指令碼是從Windows上ftp到Linux上的,Linux下的檔案結束符和Windows下的檔案結束符不一樣。在Windows上編輯的指令碼,放在Linux額上執行就會有這種問題。
網上又查了以下,解決方法是使用vim開啟指令碼,執行命令:
set fileformat=unix
儲存退出,再次執行就沒有問題了。當然,也可以在Linux上重新新建一個指令碼。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29067253/viewspace-2131547/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Solaris syntax error: unexpected end of fileError
- 配置NDK syntax error: unexpected end of file 解決Error
- syntax error near unexpected token `Error
- gzip: stdin:unexpected end of file
- Newline required at end of file but not foundUI
- syntax error near unexpected token `問題的解決Error
- shell 指令碼報錯^M: syntax error near unexpected token指令碼Error
- ScalaSigParserError: Unexpected error: Not a valid class fileError
- Nginx unexpected end of file 配置證書遇到問題,如何解決?Nginx
- CentOS7使用exp/imp時報錯:bash: syntax error near unexpected token `(CentOSError
- pecl PHP Parse error: syntax error, unexpected 'new' (T_NEW) 以及 XML缺失解決辦法PHPErrorXML
- Laravel 8使用 佇列任務出現 「 syntax error, unexpected ')' 」錯誤解決Laravel佇列Error
- Linux 5中出現的-bash: syntax error near unexpected token `('錯誤LinuxError
- Solaris awk: syntax error near line 1 awk: bailing out near line 1ErrorAI
- Binary XML file line #2: Error inflatingXMLError
- Syntax error, unrecognized expression: li[value=]ErrorZedExpress
- 【shell 】syntax error in conditional expressionErrorExpress
- exp tables sh: Syntax error: `(' is not expectedError
- 解決:npm install ERR! Unexpected end of JSON inputNPMJSON
- Oracle安裝報錯syntax errorOracleError
- IMP-00009: abnormal end of export fileORMExport
- 解決laravel出現Syntax error or access violation: 1055 ‘***‘ isn‘t in GROUP BYLaravelError
- 10g GC 啟動oms報錯Unexpected error occurred. Check error and log files.GCError
- ERROR 23 (HY000) at line 29963: Out of resources when opening fileError996
- npm install “Unexpected end of JSON input while parsing near”問題NPMJSONWhile
- An unexpected error has been detected by Java Runtime EnvironmentErrorJava
- 10.2.0.2 RAC DB ">>> ERROR IN KQLMBIVG SEE LCK TRACE FILEError
- How to Convert Class File to Java File Online?Java
- Error 15: File not found for RedhatErrorRedhat
- 萬能方法解決——You have an error in your SQL syntaxErrorSQL
- OGG-01028 Opening file errorError
- MySQL_ERROR 1231 (42000) at line XX in file 'file_name' Variable 'time_zone' can't beMySqlError
- error C2061: syntax error : identifier '__RPC__out_xcount_part'ErrorIDERPC
- npm install 出現 npm ERR! Unexpected end of JSON input while parsing near '...ostNPMJSONWhile
- HPUX Error 23 File table overflowUXError
- 記錄某次解決`Okhttp java.io.EOFException: \n not found: size=0 content= unexpected endHTTPJavaException
- 解決 eslint 的 Parsing error: Unexpected token 錯誤EsLintError
- CDH5之Unexpected error.Unable to verify database connectionH5ErrorDatabase