2015-11-05 90 views
0

下面的代碼行工作在我的數據庫服務器(UNIX)xmllint沒有shell腳本

xmllint --noout CI_PRD_TESTING.XML 

內工作,但同樣沒有shell腳本

#!/bin/bash 
export FOO="/home/data/others" 
echo $FOO 
vari=`ls -t1 CI_PRD*.XML | head -1` 
xmllint --noout $vari 

它給我的內部工作以下錯誤。爲什麼會表現這樣的...

[[email protected] others]$ bash validate_xml.sh 
/home/data/others 
"arning: failed to load external entity "CI_PRD_TESTING.XML 
[[email protected] others]$ 
+0

看看錯誤消息是如何環繞的?您的腳本中有DOS行尾。刪除它們。請參閱['bash'標記信息wiki](https://stackoverflow.com/tags/bash/info)中的第1項。 –

+0

@EtanReisner我已經從腳本中刪除了CD,仍然輸出相同。 – Mrk

+0

你做了什麼?什麼「光盤」? –

回答

1

萬元感謝伊坦賴斯納(https://stackoverflow.com/users/258523/etan-reisner)爲我提供了這個問題的答案通過評論部分本身。

寫下答案,只是爲了尋找答案部分而不是評論部分的人。

我的代碼是使用下面的命令後,在每一行的末尾有^ M,

export FOO="/home/data/others"^M 
echo $FOO^M 
vari=`ls -t1 CI_PRD*.XML | head -1`^M 
xmllint --noout $vari^M 

,它出去,它的工作如預期。

dos2unix validate_xml.sh