cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: assign http response header to command line variable in curl

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Sat, 26 Apr 2008 13:28:58 -0700

On Sat, Apr 26, 2008 at 03:24:39PM +0000, analyz.oh_at_netzero.net wrote:
>
> If I have a HTTP response header sent to me from a server such as:
>
> X-var: datadescription
>
> and I wish to assign this to a variable, what syntax should I be using when I specify:
>
> "vname = X-var" on the command line?
>
> I have tried many different things that do not transfer the contents of X-var into the variable (vname).
>
> Any help is much appreciated!

Assuming a Bourne shell, how about:

vname=`curl -s -I http://example.com/ | grep -i ^X-var: | cut -d" " -f2-`

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2008-04-26