简体   繁体   中英

xmllint not working inside shell script

The following line of code works in my db server ( unix )

xmllint --noout CI_PRD_TESTING.XML

But the same is not working inside the shell script

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

it is giving me the following error. why is it behaving like this...

[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]$

Million Thanks to Etan Reisner ( https://stackoverflow.com/users/258523/etan-reisner ) for providing me the answer to the question through the comments section itself.

Writing down the answer, just for the sake of others who look for the answers section more than the comments section.

my code was having ^M at the end of each line,

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

after using the below command, it went out and it worked as expected.

dos2unix validate_xml.sh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM