我在bash脚本中尝试使用curl和--netrc-file选项时遇到了一个问题。当我只是把curl -d "username=MYUSR&password=MYPSWD" https://st-machinexxx/api -c cookies.txt
然后它的工作正常。但是curl --netrc-file configfile.txt https://st-machinexxx/api -c cookies.txt
导致HTTP错误401。可能是什么原因呢?我试图通过添加--digest,--negotiate和--ntlm以及设置一些头来设置认证方法,但没有帮助。我使用的是curl 7.29.0,curl file.txt只包含三行:
machine st-machinexxx
login MYUSR
password MYPSWD
1条答案
按热度按时间oiopk7p51#
问题出在
netrc
文件的缩进上。标签:https://superuser.com/a/1784420/1799443由于某些未知的原因(可能是因为无法识别回车),如果你不使用缩进,你会得到这个错误。此外,我建议您在此处阅读有关
--crlf
和--use-ascii
选项的信息:https://curl.se/docs/manpage.html#--crlf