curl:(3)在URL中发现非法字符:$ {...%?}不起作用 [英] curl: (3) Illegal characters found in URL : ${...%?} doesn't work

查看:139
本文介绍了curl:(3)在URL中发现非法字符:$ {...%?}不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找解决问题的方法,特别是在



有什么想法吗?

解决方案

如果您的行以 \r ,从 $ url 中删除​​ \r 无效,因为该行

  curl -o NUL {url1%?} 

也以 \r 结尾,并再次附加到url参数。



注释掉 \r ,即

  url1 = www.domain.tld / file 
curl -o NUL $ {url1%?}##b $ b

  url1 = www.domain.tld / file#
curl -o NUL $ url1#

或conv在执行文件之前将其插入文件

  tr -d’\r’< test.sh> testWithoutR.sh 


I've been looking for a solution to my problem all the morning, especially in the 4 posts in https://stackoverflow.com having the same error name in their title but the solutions don't work for me.

I want to do several simple cURL requests put together in a Bash script. The request at the end of the file always works, whatever request it is. However the requests before return an error:

curl: (3) Illegal characters found in URL

I am pretty sure that it has something to do with the carriage return in my file. But I don't know how to deal with it. As I show in the picture below I tried to use ${url1%?}. I also tried ${url1%$'\r'}, but it doesn't change anything.

Screenshot of file + results in terminal:

Any ideas?

解决方案

If your lines end with \r, stripping away the \r from the $url won't work, because the line

curl -o NUL "{url1%?}

also ends with a \r, which is appended to the url argument again.

Comment out the \r, that is

url1="www.domain.tld/file"
curl -o NUL "${url1%?}" #

or

url1="www.domain.tld/file" #
curl -o NUL "$url1" #

or convert the file before executing it

tr -d '\r' < test.sh > testWithoutR.sh

这篇关于curl:(3)在URL中发现非法字符:$ {...%?}不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆