Sponsored Content
Top Forums Shell Programming and Scripting Parsing the http post request Post 302840993 by jdp on Tuesday 6th of August 2013 09:47:56 PM
Old 08-06-2013
Parsing the http post request

Hi,

I am trying to write a shell script to parse the post request data that it received to a xml file. Below is the post request data that script is receiving.

Code:
-----------------------------7dd2339190c8e
Content-Disposition: form-data; name="param1"

1
-----------------------------7dd2339190c8e
Content-Disposition: form-data; name="param2"

2
-----------------------------7dd2339190c8e
Content-Disposition: form-data; name="param3"

3
-----------------------------7dd2339190c8e
Content-Disposition: form-data; name="param4"

4
-----------------------------7dd2339190c8e
Content-Disposition: form-data; name="xmldata"

<ShapeInfo>
<Rectangles>
<Rectangle>
<top>47</top>
<left>169</left>
<bottom>173</bottom>
<right>343</right>
</Rectangle>
</Rectangles>
<Lines>
<Line>
<startX>349</startX>
<startY>127</startY>
<endX>499</endX>
<endY>274</endY>
</Line>
</Lines>
</ShapeInfo>

-----------------------------7dd2339190c8e--

Code:
!/bin/sh

echo "" > "file.xml"

if [ "$REQUEST_METHOD" = "POST" ]; then
    if [ "$CONTENT_LENGTH" -gt 0 ]; then
        while read -n $CONTENT_LENGTH POST_DATA <&0
        do
            echo "$POST_DATA" >> "file.xml"
         done
    fi
fi

How can I parse it and dump it into xml? Any reference?

Thanks,
Jdp
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

HTTP Query Request & Parsing returned XML output

I have a PERL script from which I need to make a HTTP request to Web Servlet (Essentially a URL with variables and values like &Variable1=AAAAAA&Variable2=BBBBBBBBB&Variable3=CCCCCCC). The Web servlet returns an XML result which needs to be parsed for the contents of the result within the program.... (15 Replies)
Discussion started by: jerardfjay
15 Replies

2. UNIX for Dummies Questions & Answers

unix script http request

Hi everybody, I have a *.vbs file which I want to run automatically. I want to know if there is anyway to implement the given example for e.g "http://255.255.255.55/script.vbs" what I mean is does anyone know how to make an http request from a unix script?? Thanks in advance!!!!!!!!!!! (1 Reply)
Discussion started by: arksal
1 Replies

3. Shell Programming and Scripting

Http request in Linux

Hi, i need a guide how to write a script which i can do a http request. Let say the request look like below; http://www.test.com?txid=1&type=service&server=linux I have a list of "txid" (in *.txt) and need to run all "txid" acordingly. So that mean, every transaction i have to refer "txid"... (7 Replies)
Discussion started by: malaysoul
7 Replies

4. UNIX for Dummies Questions & Answers

http request forward

Hi, Maybe it's a stupid question, anyway here goes.. I have an Apache web server on Solaris box, let's say A, with a public ip and a web application on a Linux box, uhmmm B, on a private lan with a private ip. I want the people from outside to connect to the app, but its inside the lan,... (4 Replies)
Discussion started by: piltrafa
4 Replies

5. UNIX for Dummies Questions & Answers

HTTP request

Can anybody tell about http request processing in shell script..? (3 Replies)
Discussion started by: noufal
3 Replies

6. Shell Programming and Scripting

How to send XML data using HTTP Post Request

How to hit HTTP Post Request along with sending XML data to a Remote server through command line utility like wget (or anything else). (0 Replies)
Discussion started by: sandeep reddy
0 Replies

7. UNIX for Dummies Questions & Answers

cant make a http get request using wget

Hi all, Im trying to make an http get request to a web service from a linux machine like below and i get ERROR 500 wget http://10.1.21.236:8585/pns.asmx/Sen...&msgBody=werty 25018 $ --19:06:32-- http://10.1.21.236:8585/pns.asmx/Sen...erName=serverA Connecting to 10.1.21.236:8585...... (1 Reply)
Discussion started by: elthox
1 Replies

8. UNIX for Advanced & Expert Users

Issue in Curl to send http POST request with attachment/multipart

Hi, I am using curl to hit a url using http in solaris 10 using commandline, I want to transfer an attachment(using multipart curl -F) also as a part of the request. If anyone has used kindly help me with the syntax. I am using below command: Code: /usr/local/bin/curl -v... (1 Reply)
Discussion started by: manishmaha
1 Replies

9. Programming

C++ http GET request using sockets

Hello I am trying to communicate with a server that is ready to accept HTTP GET requests and send back data per the request. However, I have very little experience in socket programming and I don't really know how to debug this. Googling on the web hasn't yielded much, except people saying I... (2 Replies)
Discussion started by: flagman5
2 Replies

10. Shell Programming and Scripting

http request

I am running a website but I still have problems with the "service temporarily unavailable error". I want to make a simple check if the website is up and running. Does anybody has an idea how to do it? (the site is password protected, so you have to add a user and pwd before logging in). ... (2 Replies)
Discussion started by: jurgen
2 Replies
Courriel::Header::Disposition(3pm)			User Contributed Perl Documentation			Courriel::Header::Disposition(3pm)

NAME
Courriel::Header::Disposition - The content disposition for an email part VERSION
version 0.29 SYNOPSIS
my $disp = $part->content_disposition(); print $disp->is_inline(); print $disp->is_attachment(); print $disp->filename(); my %attr = $disp->attributes(); while ( my ( $k, $v ) = each %attr ) { print "$k => $v "; } DESCRIPTION
This class represents the contents of a "Content-Disposition" header attached to an email part. Such headers indicate whether or not a part should be considered an attachment or should be displayed to the user directly. This header may also include information about the attachment's filename, creation date, etc. Here are some typical headers: Content-Disposition: inline Content-Disposition: multipart/alternative; boundary=abcdefghijk Content-Disposition: attachment; filename="Filename.jpg" Content-Disposition: attachment; filename="foo-bar.jpg"; creation-date="Tue, 31 May 2011 09:41:13 -0700" API
This class supports the following methods: Courriel::Header::Disposition->new_from_value( ... ) This takes two parameters, "name" and "value". The "name" is optional, and defaults to "Content-Disposition". The "value" is parsed and split up into the disposition and attributes. Courriel::Header::Disposition->new( ... ) This method creates a new object. It accepts the following parameters: o name This defaults to 'Content-Type'. o value This is the full header value. o disposition This should usually either be "inline" or "attachment". In theory, the RFCs allow other values. o attributes A hash reference of attributes from the header, such as a filename, creation date, size, etc. The keys are attribute names and the values can either be strings or Courriel::HeaderAttribute objects. Values which are strings will be inflated into objects by the constructor. This is optional, and can be an empty hash reference or omitted entirely. $ct->name() The header name, usually "Content-Disposition". $ct->value() The raw header value. $disp->disposition() Returns the disposition value passed to the constructor. $disp->is_inline() Returns true if the disposition is not equal to "attachment". $disp->is_attachment() Returns true if the disposition is equal to "attachment". $disp->filename() Returns the filename found in the attributes, or "undef". $disp->creation_datetime(), $disp->last_modified_datetime(), $disp->read_datetime() These methods look for a corresponding attribute ("creation-date", etc.) and return a DateTime object representing that attribute's value, if it exists. $disp->attributes() Returns a hash (not a reference) of the attributes passed to the constructor. Attributes are Courriel::HeaderAttribute objects. The keys of the hash are all lower case, though the original casing is preserved in the "name()" returned by the Courriel::HeaderAttribute object. $disp->attribute($key) Given a key, returns the named Courriel::HeaderAttribute object. Obviously, this value can be "undef" if the attribute doesn't exist. Name lookup is case-insensitive. $disp->attribute_value($key) Given a key, returns the named attribute's value as a string. Obviously, this value can be "undef" if the attribute doesn't exist. Name lookup is case-insensitive. The attribute is a Courriel::HeaderAttribute object. $disp->as_header_value() Returns the object as a string suitable for a header value (but not folded). EXTENDS
This class extends Courriel::Header. ROLES
This class does the Courriel::Role::HeaderWithAttributes role. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT AND LICENSE
This software is Copyright (c) 2012 by Dave Rolsky. This is free software, licensed under: The Artistic License 2.0 (GPL Compatible) perl v5.14.2 2012-03-07 Courriel::Header::Disposition(3pm)
All times are GMT -4. The time now is 05:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy