Get XML, parse output, get a date and calculate differences?
by riahc3 from LinuxQuestions.org on (#5JFMB)
Hello
I know very little bash so hang with me here.
I want to read a URL that returns XML from bash. It returns something like this:
<response status="success">
<result>
<entry name="hello">
<name>hello</name>
<a-valid-date>May 3 07:00:00 2031 GMT</a-valid-date>
</entry>
</result>
</response>
My only real intrest is "a-valid-date" I want to get that value and work with it: If today is 30 days or less away from it, I return something. If today is more than 30 days AND less than 60 days away from it, I return something else. If today is more than 60 days, I return something else.
I imagine I have to do something with grep, maybe a loop, etc but other than that, I dont know what to do, sorry.
Can someone help me out?
Thanks
I know very little bash so hang with me here.
I want to read a URL that returns XML from bash. It returns something like this:
<response status="success">
<result>
<entry name="hello">
<name>hello</name>
<a-valid-date>May 3 07:00:00 2031 GMT</a-valid-date>
</entry>
</result>
</response>
My only real intrest is "a-valid-date" I want to get that value and work with it: If today is 30 days or less away from it, I return something. If today is more than 30 days AND less than 60 days away from it, I return something else. If today is more than 60 days, I return something else.
I imagine I have to do something with grep, maybe a loop, etc but other than that, I dont know what to do, sorry.
Can someone help me out?
Thanks