2

I need some help to finalize a command line. I need to get a property name "server.port" in some files "applications.properties", and then make a curl on "myIp:server.port/health"

I get properties value with the following line, and the curl command get the param, but i can't add IP before and /health after.

Could you help me to finalize this command line ?

cat ms-something-*/application.properties | grep server.port | awk '{print $3}' | xargs curl

So without the last element "xargs curl", the line return a list of port number. but i need to add the ip (for example 8.8.8.8) and /health, to call curl on "8.8.8.8:server.port/health"

1
  • Can you post the contents of application.properties file on which grep on server port? Commented Nov 16, 2016 at 10:10

2 Answers 2

4
cat ms-something-*/application.properties | grep server.port | awk '{print "8.8.8.8:"$3"/health"}' | xargs curl

should work for you, if I correctly understand your question...

Sign up to request clarification or add additional context in comments.

2 Comments

If I understand right, you are missing a : right after the IP and just before port value.
That's it ! i was trying to echo something but i don't think about concat inside the print... It work fine. thanks for your help.
1

You can achieve this also with a for loop.

for port in $(cat ms-something-*/application.properties | grep server.port | awk '{print $3}') ; do 
    curl "8.8.8.8:${port}/health"
done

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.