Parsing Cookies in bash cgi scripts

I am trying to transfer from less of query strings and more of cookies. So i need to make a script that parses the cookies from the HTTP_COOKIE request header. The format of the cookies is:

{cookiename}={cookievalue} {other-cookies}={other-cookie-value}

My options are to either only look for a set {cookiename} and set that to the value...or to scan through the full list of cookies and parse it so the bash variable $cookiename will equal {cookievalue}

Answers


Assuming best case scenario, your cookies may already be Bash friendly. In this case you can source the cookie file.

. cookies.txt

and Bash will save each cookie to a variable. However as many will tell you the file is likely not formatted correctly, perhaps having one or more of these problems

  • invalid characters in variable name
  • no quotes around values

in which case you would need to add that using sed before sourcing the file.


Need Your Help

elementToPropertyMapping in RestKit

xml cocoa-touch ios parsing restkit

I am learning RestKit. I came across the elementToPropertyMapping feature which it provides. I am wondering whether I can use this mapping for xml documents? or is it just for JSON?

How do I parse the results from a JSON output into a data frame?

json r data.frame

In trying to analyze tweets from a hashtag, I am able to obtain 100 results at a time via this call.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.