curl: (3) Illegal characters found in URL

半城伤御伤魂 提交于 2019-12-05 01:17:54

So to summarize, as a step-by step for future reference,

Running uname -A can reveal what system is being used for example revealing here it is Cygwin.

This leads us to thinking about Windows vs Linux differences.

One of the known differences are windows/dos line endings. This can be revealed, as well as with generally checking all contents of a text file, with:

cat -A ips.txt

Now if you find it contains ^M line endings, as it did here, it means the line endings are dos/windows and not *nix line endings (which would show only lines ending with $)

To fix this, simply run

dos2unix ips.txt

Now, if you run your original command with this fixed input file, it seems CURL is happy with it and it works.

Thank you as well MistaGill, I learned about ipinfo.io from this post.

I ran into a similar situation, and a possible quick fix is to add a -d "\n" flag to xargs:

cat ips.txt | xargs -d "\n" -I% curl http://ipinfo.io/%/region

This prevents new lines from being interpreted as part of the argument being passed to curl.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!