gpt4 book ai didi

xmllint 在 shell 脚本中不工作

转载 作者:太空宇宙 更新时间:2023-11-04 10:44:47 24 4
gpt4 key购买 nike

以下代码行适用于我的数据库服务器 (unix)

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

它给我以下错误。为什么会这样……

[testuser@mk-testdb others]$ bash validate_xml.sh
/home/data/others
"arning: failed to load external entity "CI_PRD_TESTING.XML
[testuser@mk-testdb others]$

最佳答案

非常感谢 Etan Reisner (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

关于xmllint 在 shell 脚本中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33547874/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com