Hi guys,
it had been a little bit quite the last time but by now I got a little something you might need to. In my current project I had been running into the problem that I wanted to address a certain Javaservice with a deployment script on the shell. This was the easy part , the even harder part, which took some time talking to uncle google to get an answer, was that this service needed an authentication by a cookie which needs to have a valid session id in it.
Solution is, the time you got to know how it works, quite easy:
#!/bin/bash
CookieFileName=cookies.txt
curl --cookie $CookieFileName --cookie-jar \
$CookieFileName --user-agent Mozilla/4.0 POST \
--data "username={yourUserName}&password={yourPassword}" \
http://websiteToAuthOn.com -v
What this basically does is to save the Http Header information in to the cookies.txt file so we can use it later on for instance like this:
curl --cookie cookies.txt --user-agent Mozilla/4.0 \ -X GET http://websiteToAuthOn.com/page/you/want
Tada,… you loged into a page on shell, got a cookie and are ready to play.

