Curl build with bash script -


i want create curl #!/bin/sh script , part giving me headache is:

str="-xget -v -h 'authorization: bearer "$token"' https://my_endpoint/sth?" echo $str  con="$(curl $str)" 

the echo there is:

-xget -v -h 'authorization: bearer eyjhbgcioijsuzi1niisinr5cci6ikpxuyj9.eyjlehaioje0ntm5nzixodcsinvzzxjuyw1lijoid2luz3uty2xpzw50lwfkbwluqhnwzwljagvymjewlmnvbsisimlhdci6ije0ntm4odu3odcifq.adlcrv4yph6owwgmlak2rsnc95wk17ulflcisvnwbkea93g4wuq-bmrjnhqeuigsfxsynamgmi36ggc2pytwhkqk8liyrmjth80tggbycnnua2lm26iz2viumk1cj-bh3-dh4hmqsm_hozafnvqgqi9p5j4cbz8ecf_mkc3iq-7enxriktkgakf69-jpffa_9yo26jzzedpymowa-lrpafwptyinzmkauq2shjudwtgmelayzkguooxrz8tgvv9yeb-oneoy54grslb4ogvzawwcj2y6vxmvnpan5wiuzmylqtghnqfr9mop4jid1ravjwt7strp9bchbxd55ctyoeq-ospdv6wkgb07ctcri0spx9ervsab0xf1mh9xkavjoq_dnnpktxlqixmbbosxehjye9k6z30c3uwhcgccndeehxphi7d2bro3m_3fjpksywwk5dxhxmkfpj4flf05jo31ffioj8q7h3c5nevxvk_kes-jpy5ip5xry1dv9p8bwpewfk1-qqrxz1mmnildlxdb9cxe9tm6eo4rxo71h2o4z1dhmnvhhctsatzywsjie3o8ym5o0osms3wh3ej-is572lfv-zqskt3fq927jlvwotd9hhmt2mopf8zg5cdnd-hclzufj7qoi-a0afbn2ct3fccbxj8l4' https://my_endpoint/sth? 

and when copy terminal , paste curl works, in verbose log find:

-xget -v -h 'authorization: bearer eyjhbgcioijsuzi1niisinr5cci6ikpxuyj9.eyjlehaioje0ntm5nzixodcsinvzzxjuyw1lijoid2luz3uty2xpzw50lwfkbwluqhnwzwljagvymjewlmnvbsisimlhdci6ije0ntm4odu3odcifq.adlcrv4yph6owwgmlak2rsnc95wk17ulflcisvnwbkea93g4wuq-bmrjnhqeuigsfxsynamgmi36ggc2pytwhkqk8liyrmjth80tggbycnnua2lm26iz2viumk1cj-bh3-dh4hmqsm_hozafnvqgqi9p5j4cbz8ecf_mkc3iq-7enxriktkgakf69-jpffa_9yo26jzzedpymowa-lrpafwptyinzmkauq2shjudwtgmelayzkguooxrz8tgvv9yeb-oneoy54grslb4ogvzawwcj2y6vxmvnpan5wiuzmylqtghnqfr9mop4jid1ravjwt7strp9bchbxd55ctyoeq-ospdv6wkgb07ctcri0spx9ervsab0xf1mh9xkavjoq_dnnpktxlqixmbbosxehjye9k6z30c3uwhcgccndeehxphi7d2bro3m_3fjpksywwk5dxhxmkfpj4flf05jo31ffioj8q7h3c5nevxvk_kes-jpy5ip5xry1yirgablv9p8bwpewfk1-qqrxz1mmnildlxdb9cxe9tm6eo4rxo71h2o4z1dhmnvhhctsatzywsjie3o8ym5o0osms3wh3ej-is572lfv-zqskt3fq927jlvwot5mn9hhmt2mopf8zg5c6udnd-hclzufj7qoi-a0afbn2ct3fccbxj8l4' https://my_endpoint/sth? * rebuilt url to: bearer/   % total    % received % xferd  average speed   time    time     time  current                                  dload  upload   total   spent    left  speed   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* not resolve host: bearer * closing connection 0 curl: (6) not resolve host: bearer * rebuilt url to: eyjhbgcioijsuzi1niisinr5cci6ikpxuyj9.eyjlehaioje0ntm5nzixodcsinvzzxjuyw1lijoid2luz3uty2xpzw50lwfkbwluqhnwzwljagvymjewlmnvbsisimlhdci6ije0ntm4odu3odcifq.adlcrv4yph6owwgmlak2rsnc95wk17ulflcisvnwbkea93g4wuq-bmrjnhqeuigsfxsynamgmi36ggc2pytwhkqk8liyrmjth80tggbycnnua2lm26iz2viumk1cj-bh3-dh4hmqsm_hozafnvqgqi9p5j4cbz8ecf_mkc3iq-7enxriktkgakf69-jpffa_9yo26jzzedpymowa-lrpafwptyinzmkauq2shjudwtgmelayzkguooxrz8tgvv9yeb-oneoy54grslb4ogvzawwcj2y6vxmvnpan5wiuzmylqtghnqfr9mop4jid1ravjwt7strp9bchbxd55ctyoeq-ospdv6wkgb07ctcri0spx9ervsab0xf1mh9xkavjoq_dnnpktxlqixmbbosxehjye9k6z30c3uwhcgccndeehxphi7d2bro3m_3fjpksywwk5dxhxmkfpj4flf05jo31ffioj8q7h3c5nevxvk_kes-jpy5ip5xry1yirgablv9p8bwpewfk1-qqrxz1mmnildlxdb9cxe9tm6eo4rxo71h2o4z1dhmnvhhctsatzywsjie3o8ym5o0osms3wh3ej-is572lfv-zqskt3fq927jlvwot5mn9hhmt2mopf8zg5c6udnd-hclzufj7qoi-a0afbn2ct3fccbxj8l4'/ * not resolve host: eyjhbgcioijsuzi1niisinr5cci6ikpxuyj9.eyjlehaioje0ntm5nzixodcsinvzzxjuyw1lijoid2luz3uty2xpzw50lwfkbwluqhnwzwljagvymjewlmnvbsisimlhdci6ije0ntm4odu3odcifq.adlcrv4yph6owwgmlak2rsnc95wk17ulflcisvnwbkea93g4wuq-bmrjnhqeuigsfxsynamgmi36ggc2pytwhkqk8liyrmjth80tggbycnnua2lm26iz2viumk1cj-bh3-dh4hmqsm_hozafnvqgqi9p5j4cbz8ecf_mkc3iq-7enxriktkgakf69-jpffa_9yo26jzzedpymowa-lrpafwptyinzmkauq2shjudwtgmelayzkguooxrz8tgvv9yeb-oneoy54grslb4ogvzawwcj2y6vxmvnpan5wiuzmylqtghnqfr9mop4jid1ravjwt7strp9bchbxd55ctyoeq-ospdv6wkgb07ctcri0spx9ervsab0xf1mh9xkavjoq_dnnpktxlqixmbbosxehjye9k6z30c3uwhcgccndeehxphi7d2bro3m_3fjpksywwk5dxhxmkfpj4flf05jo31ffioj8q7h3c5nevxvk_kes-jpy5ip5xry1yirgablv9p8bwpewfk1-qqrxz1mmnildlxdb9cxe9tm6eo4rxo71h2o4z1dhmnvhhctsatzywsjie3o8ym5o0osms3wh3ej-is572lfv-zqskt3fq927jlvwot5mn9hhmt2mopf8zg5c6udnd-hclzufj7qoi-a0afbn2ct3fccbxj8l4' * closing connection 1 curl: (6) not resolve host: eyjhbgcioijsuzi1niisinr5cci6ikpxuyj9.eyjlehaioje0ntm5nzixodcsinvzzxjuyw1lijoid2luz3uty2xpzw50lwfkbwluqhnwzwljagvymjewlmnvbsisimlhdci6ije0ntm4odu3odcifq.adlcrv4yph6owwgmlak2rsnc95wk17ulflcisvnwbkea93g4wuq-bmrjnhqeuigsfxsynamgmi36ggc *   trying 54.228.198.226... * connected my_endpoint (54.228.198.226) port 443 (#2) * tls 1.2 connection using tls_ecdhe_rsa_with_aes_128_gcm_sha256 * server certificate: *.herokuapp.com * server certificate: digicert sha2 high assurance server ca * server certificate: digicert high assurance ev root ca > /api/sth? http/1.1 > host: my_endpoint/sth? > user-agent: curl/7.43.0 > accept: */* > < http/1.1 401 unauthorized < connection: keep-alive < server: nginx/1.8.0 < content-type: application/json < transfer-encoding: chunked < x-powered-by: php/5.6.17 < cache-control: no-cache < allow: < date: wed, 27 jan 2016 09:09:49 gmt < via: 1.1 vegur < { [59 bytes data] 100    48    0    48    0     0     41      0 --:--:--  0:00:01 --:--:--     0 * connection #2 host my_endpoint left intact 

what's wrong header?

you can use

eval curl $str "https://my_endpoint" > 'output_file' 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -