0

basically i'm doing a curl and grepping some stuff. But, i want set the output of this curl to a variable, to then use it on another curl. e.g:

curl -u asd:asd http://zzz:123/aa/aa.aaa?cmd=ls | grep -B1 -E '<bbb>[4-7]\d{8,}' | grep yyy | tail -n 1 | sed -n -e 's/.*<xxx>\(.*\)<\/xxx>.*/\1/p')

but then I want set the output to a var and use it:

RUN aaa=$(previous curl) && curl -u asd:asd http://$aaa.com

tried with ${aaa}, with "$aaa", etc... didn't work. any solutions?

UPDATE: something wrong is happening in previous curl 'cause doesn't return the value. probably for not doing the curl

asd123
  • 31
  • 6

1 Answers1

0

I fear you will not be able to acheive this, because from my understanding RUN statement is to execute a command. To store value you'll have use SET.

For me the following workaround helped

RUN export aaa=$(curl -u asd:asd http://$aaa.com);echo aaa;

You can add the downsteam commands that will use the variable aaa towards right of the semicolon

helvete
  • 2,455
  • 13
  • 33
  • 37