スポンサーリンク
最近APIを扱うことが多くなり、curlコマンドを多用するようになりました。
昔(5年くらい前)はCLIのhttpクライアントと言えばwgetのほうが一般的だった気がするのですが、ここ最近ではすっかりcurlが定着した気がします。
さて、そんなcurlを使っていた時にあるエラーで困ってしまったのでメモしておきます。
APIとは?をざっくり説明します
Pythonで書ける検証自動化:RobotFrameworkとは
curlを使ってシェルスクリプトを書いた時のことです。リダイレクトの処理をさせる必要があったのですが、リダイレクト先ではHTTPメソッドを変えたいため、自分でURLを変数に入れ、複数回curlを実行するようなスクリプトを書きました。
つまり、こんな感じです
# リダイレクト元へのcurl。${REDIRECT_URL}にリダイレクト先が格納される
REDIRECT_URL=`curl -D - -X POST -d "username=${USERNAME}" -d "password=${PASSWORD}" 'https://example.com/login' | awk '$1~/^Location/{print $2}'`
# リダイレクト先へのcurl
curl -X GET "${REDIRECT_URL}"
これを実行すると、以下のようなエラーが出ました。
# curl -X GET "${REDIRECT_URL}"
curl: (3) Illegal characters found in URL
ちなみにこの時、${REDIRECT_URL}には以下のような文字列が格納されています。
# echo ${REDIRECT_URL}
https://example.com/auth/authorize?client_id=client&response_type=code+id_token&redirect_uri=https://example2.com/callback&state=abcdefghijk&scope=openid&nonce=ef123456789
確かに怪しい文字がいっぱい入ってはいますが、ちゃんとダブルクオーテーションでくくっているし、何が問題なんだろう?と小一時間悩みました。
結論から言うと、末尾に改行が入っていたのが問題でした。
そして以下のように修正することで正しく動作しました。
curl -X GET "${REDIRECT_URL%$'\r'}"
上記の *%$'\r' * という部分でbashの変数展開の時に末尾の'\r'を削除しています。
なかなか該当の情報が出てこず苦労しました。。
スポンサーリンク
2022/05/20 20:21:36
purchase modafinil pills buy modafinil 100mg online cheap
2022/05/21 03:09:54
2022/05/21 04:52:36
2022/04/08 03:19:37
sildenafil brand name sildenafil dosage for pulmonary hypertension
2022/04/08 10:49:23
cialis 20mg buy tadalafil 20mg price
2022/04/08 16:56:38
viagra coupons order generic viagra
2022/04/08 22:13:03
generic cialis tadalafil best buys solubility of tadalafil
2022/04/09 16:04:56
viagra story sublingual viagra viagra for men п»їviagra
2022/04/10 01:46:17
review of tadalafil tadalafil vs sildenafil citrate
2022/04/12 00:09:57
sam's club pharmacy hours pioneer rx pharmacy software reviews
2022/04/12 07:47:35
canadian 0nline pharmacy canadian association of pharmacy students and interns
2022/04/12 13:33:40
sildenafil citrate for sale sildenafil citrate 20 mg tablet
2022/04/12 14:56:26
where to buy sildenafil usa canadian viagra
2022/04/13 15:44:52
chantix canadian pharmacy longs drug store pharmacy
2022/04/13 23:22:09
cialis free canada cialis 20mg canada
2022/04/14 05:00:45
super active viagra cheap viagra pills from india
2022/04/14 11:48:46
no rx pharmacy viagra canada drugs
2022/04/15 03:01:31
levitra 10 mg costo levitra company
2022/04/15 09:08:06
pre pharmacy schools online nuvigil online canadian pharmacy
2022/04/16 17:05:44
where can i buy stromectol ivermectin injectable dosage for chickens
2022/04/17 01:46:44
ivermectin and cancer ivermectin and fluvoxamine
2022/04/17 05:51:48
purity solutions tadalafil tadalafil dose
2022/04/17 13:22:06
cialis 100 mg usa cialis otc 2017
2022/04/18 04:39:46
custom rx compounding pharmacy best online canadian pharmacy
2022/04/18 10:38:44
viagra online order in india best generic viagra brand
2022/04/20 01:48:45
cialis buy paypal generic vs brand name cialis
2022/04/20 09:44:36
buy levitra where buy online levitra usa
2022/04/20 13:48:08
viagara cialis levitra generic cialis no prescription paypal
2022/04/20 20:24:55
200 mg viagra sildenafil purchase india
2022/04/21 10:53:43
levitra for bph levitra for ed
2022/04/21 17:02:06
meijer pharmacy store hours how to buy prescription drugs from canada
2022/04/23 06:20:05
is it legal to buy prescription drugs from canada? sky pharmacy online
2022/04/23 14:09:13
victoza canadian pharmacy is canada drug pharmacy legitimate
2022/04/23 18:16:29
canada drug pharmacy richmond bc online prescription drugs
2022/04/24 00:51:12
Zenegra Clomid
2022/04/24 15:39:29
how to report someone selling prescription drugs detox prescription drugs
2022/04/24 21:38:00
Precose reviews canadian pharmacy online
2022/04/29 18:07:09
sildenafil over the counter usa cost of prescription viagra https://sgiviagraikn.com/
2022/04/30 01:40:41
overseas pharmacy no prescription best drugstore eyebrow pencil https://jzpharmacyukj.com/
2022/04/30 05:44:16
another name for sildenafil para que sirve sildenafil 100 mg https://sildenafilkiol.com/
2022/04/30 12:13:24
legitimate canadian mail order pharmacy french pharmacy online https://dtupharmyjn.com/
2022/05/01 02:33:17
how long before levitra takes effect generic levitra https://glevitrargu.com/
2022/05/01 08:34:11
what does ivermectin treat in dogs oral ivermectin for rosacea https://stromectolujlo.com/
2022/05/03 20:24:58
generic viagra canadian pharmacy online pharmacies uk
2022/05/04 03:44:20
potenzpillen levitra viagra levitra vergleich https://xclevitradb.com/
2022/05/04 14:26:18
lilly cialis 20mg where to buy cialis in singapore https://dccialisxvf.com/
2022/05/05 10:27:01
viagra 1500mg viagra pills pharmacy https://aviagrasbt.com/
2022/05/05 18:02:05
provigil medication provigil ca purchase modafinil for sale
2022/05/09 00:17:08
hydroxychlor 200 mg chloroquine generic
2022/05/09 14:21:23
marine pharmacy canada pharmacy store requirements
2022/05/09 21:40:36
levitra wiki www levitra com https://xclevitradb.com/
2022/05/10 01:40:20
sildenafil near me what does sildenafil do https://sildenafilkiol.com/
2022/05/10 08:08:31
cialis without presciption cheap cialis 40 mg https://dccialisxvf.com/
2022/05/10 21:44:04
levitra duration levitra generic usa https://glevitrargu.com/
2022/05/11 03:59:27
viagra online 100mg generic viagra 150 mg https://aviagrasbt.com/
2022/05/14 09:10:22
cheap dissertation help
get help with dissertation
writing a dissertation conclusion
2022/05/14 16:59:30
kamagra online pharmacy Abilify
2022/05/15 00:24:11
levitra lowest price levitra 20mg uk https://xclevitradb.com/
2022/05/15 04:22:06
viagra sildenafil sildenafil pill identification https://sildenafilkiol.com/
2022/05/15 04:10:54
what does dissertation mean
need dissertation help
dissertation help in houston
2022/05/16 00:57:47
what is the real cost of levitra order levitra online canada https://glevitrargu.com/
2022/05/16 03:10:17
dissertation title generator
sample dissertation
dissertation printing
2022/05/16 04:58:52
generic modafinil 200mg cost modafinil 200mg brand modafinil 100mg
2022/05/17 23:48:37
order provigil 200mg for sale modafinil tablet
2022/05/18 20:26:23
2022/05/18 20:08:03
canadian pharmacy reviews 2017 online medicine shopping
2022/05/19 02:23:11
modafinil 100mg us order provigil 200mg sale
2022/05/19 03:34:04
generic levitra suppliers levitra shop uk https://xclevitradb.com/
2022/05/19 07:35:05
apodefil sildenafil 50 mg how to use sildenafil 20 mg for ed https://sildenafilkiol.com/
2022/05/19 13:57:24
cheap canadian cialis price comparison cialis https://dccialisxvf.com/
2022/05/19 15:50:00
dissertation proposal writing tutorial
uf dissertation award
quantitative dissertation help
2022/05/19 22:04:22
2022/05/20 04:02:13
levitra uses levitra 40 mg canada https://glevitrargu.com/
2022/05/20 10:04:40
generic viagra soft tabs 100mg sildenafil 20 mg without a prescription https://aviagrasbt.com/