Thursday, 15 April 2010

bash - Extract value via OSX Terminal from .html for "curl" submission within a single script -



bash - Extract value via OSX Terminal from .html for "curl" submission within a single script -

how extract variable value of next line of html page via terminal submit afterwards via "curl -d" in same script?

<input type="hidden" name="au_pxytimetag" value="1234567890">

edit: how transfer extracted value "curl -d" command within single script? might silly question, i'm total noob. =0)

edited:

i cannot tell question trying do. thought trying extract variable file, seems want firstly, file, secondly extract variable, , thirdly, utilize variable else... let's address each of steps:

firstly want grab page using curl,

curl www.some.where.com

and page output on terminal. want search on page, need

curl www.some.where.com | awk

or

curl www.some.where.com | grep

but want set variable, need do

var=$(curl www.some.where.com | awk something)

or

var=$(curl www.some.where.com | grep something)

the actual command think want is

var=$(curl www.some.where.com | awk -f\" '/au_pxytimetag/{print $(nf-1)}')

then want utilize variable var curl operation, need do

curl -d "param1=$var" http://some.url.com/somewhere

original answer

i'd utilize awk this:

var=$(awk -f\" '/au_pxytimetag/{print $(nf-1)}' yourfile)

to take sec lastly field on line containing au_pxytimetag using " field separator.

then can utilize this

curl -d "param1=$var&param2=somethingelse" http://some.url.com/somewhere

osx bash curl

No comments:

Post a Comment