0

I would like to pass a few curl variables like time_pretransfer, time_connect in variables on my script.

curl -skw "\ntime_connect: %{time_connect}s\ntime_namelookup: %{time_namelookup}s\ntime_pretransfer: %{time_pretransfer}\ntime_starttransfer: %{time_starttransfer}s\ntime_redirect: %{time_redirect}s\ntime_total: %{time_total}s\n\n"  http://foolproofcode.com

But I can't see how to do it, because with a grep I can get only one variable.

1 Answer 1

0

Make your output a bit more machine-readable and use read:

read time_connect time_namelookup time_pretransfer time_starttransfer time_redirect time_total \
< <(curl -skw '%{time_connect} %{time_namelookup} %{time_pretransfer} %{time_starttransfer} %{time_redirect} %{time_total}' http://foolproofcode.com -o /dev/null)

# Then you can use the variables, e.g.
echo $time_total
1
  • In my script I have the url in variable style var="xxxx.xx/xxx?xx\=xxx" and if I remplace the url with $var, but the commende dosent work fine. You have any idea way? i suspect the \ charter. I test var='xxx' end "$var" and other varient
    – The33Coder
    Nov 13, 2019 at 17:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .