• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1038
  • Last Modified:

Trying to post data to a session using Gnu WGET for DOS/Windows

I am using WGET to send commands to a Java Application Server.

So far, I have successfully "logged on" and been able to retrieve information from the Java Application Server into my script.

However, I am now trying to POST information to the JAS server - and this is where I am starting to get into issues.

I captured the following URL and POST information that I need to try and plug in :

URL : http://{webserver}:{port}/manage/ajax
POST Data : <request><setAttribute hostName "{hostname}" hostPort="{hostport}" objectName="jde:instanceName={JDEInstanceName},targetType=webserver,metricName=user_manager,metricType=runtime" attribute="loginDisabledMessage" value="WARNING - This System is Down currently">Warning - This System is Down currently</setAttribute></request>

The main issue is that I am using GNU Wget for DOS / Windows - and, as such, double quotes are being interpreted in DOS.  I am therefore thinking that I should be streaming the POST information using --post-file instead of --post-data, but I don't have much experience (or cannot find examples) of using this.  Any assistance would be very gratefully accepted !  Thankyou in advance....


0
altquark
Asked:
altquark
  • 4
  • 2
1 Solution
 
mikelfritzCommented:
Put the data in a file called post.txt

Then:

wget --post-file=post.txt  http://{webserver}:{port}/manage/ajax
0
 
altquarkAuthor Commented:
wget is answering "Length: unspecified" - is this ok ?  Is there a way to specify the length of the post-file somehow ?
0
 
mikelfritzCommented:
I think that's normal.  Did it transfer the text?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
altquarkAuthor Commented:
OK - excuse the long message here, but I thought it was probably time to really get into the nitty gritty (after all, I've been pulling MY hair out all day, might as well let others do the same !!!)

Here is the wget output :

--2009-07-13 14:53:59--  http://{server}:{port}/manage/ajax
Resolving {server}... 192.168.1.22
Connecting to {server}|192.168.1.22|:{port}... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified
Saving to: `TARGET/ajax'

    [ <=>                                   ] 0           --.-K/s   in 0s

2009-07-13 14:53:59 (0.00 B/s) - `TARGET/ajax' saved [0]

----------------
My issue is that the result - "Target/ajax" - is 0 bytes in length, and it seems that wget isn't sending the correct stream, or isn't waiting long enough for a response, or something weird and wonderful.

Now, I've got Wireshark - and I'm capturing the ethernet packets and performing a comparison as follows (I've had to replace some of the server names and ports due to corporate security)....

Here are the original packets :

PACKET1 (from CLIENT to SERVER)
---------------
Ôò¡          ÿÿ     aS[J®½      ¬ÆÙ? !p6kS E }¹@ ¬#
#I

É      à#'³JæR\æPü þ
  POST /manage/ajax HTTP/1.1
Accept: */*
Accept-Language: en-us
Cache-Control: no-cache
Content-Type: text/xml; charset=UTF-8
Referer: http://{server}:{port}/manage/target?targetType=webserver&action=disableLogins
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; CON; iy1jx3hbE7tHiIVELGlZk4493682TVegQ23afJrerSNW22H9YHe7sKpDDnMY5P$#@#$i2A==; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Host: {server}:{port}
Content-Length: 271
Connection: Close
Cookie: JSESSIONID=0a0ac9162327797ba6e26e784080aa12ba95443898f0
---------------
PACKET2 (from CLIENT to SERVER)
---------------
Ôò¡          ÿÿ     aS[Jν E  E   ¬ÆÙ? !p6kS E 7}º@ ¬¬z
#I

É      à#'³MMR\æPü üµ  <request><setAttribute hostName="{serverfullURL}" hostPort="{port}" objectName="jde:instanceName={instance},targetType=webserver,metricName=user_manager,metricType=runtime" attribute="loginDisabledMessage" value=""></setAttribute></request>
---------------
PACKET3 (from SERVER to CLIENT)
Ôò¡          ÿÿ     aS[J½ê M  M   !p6kS ¬ÆÙ? E ?«@ }ï

É
#I#'      àR\ijN\Pü0#_  <result>
   <setAttribute hostName="{serverFull URL}" hostPort="{ServerPort}" objectName="jde:instanceName={Instance},targetType=webserver,metricName=user_manager,metricType=runtime" attribute="loginDisabledMessage" value="" result="success"/>
</result>
---------------
Note the final "success" - which indicates exactly what I want.

Now, here are the packets returned when I use WGET to perform the exact same (I hope) scenario :
Command run :

wget -nd --directory-prefix=TARGET --load-cookies cookies.txt --user-agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; CON; iy1jx3hbE7tHiIVELGlZk4493682TVegQ23afJrerSNW22H9YHe7sKpDDnMY5P$#@#$i2A==; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)" --post-file=dislogins.txt http://{server}:{port}/manage/ajax

****dislogins.txt :
 <request><setAttribute hostName="{FullServerURL}" hostPort="{ServerPort}" objectName="jde:instanceName={instance},targetType=webserver,metricName=user_manager,metricType=runtime" attribute="loginDisabledMessage" value=""></setAttribute></request>

PACKET1 (Client to Server):
Ôò¡          ÿÿ     i [J)¾         ¬ÆÙ? !p6kS E òL@ ¬|-
#I

É
'#'Fè\£ìU!Pü ýp  POST /manage/ajax HTTP/1.0
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; CON; iy1jx3hbE7tHiIVELGlZk4493682TVegQ23afJrerSNW22H9YHe7sKpDDnMY5P$#@#$i2A==; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Accept: */*
Host: {server}:{port}
Connection: Keep-Alive
Cookie: JSESSIONID=0a0ac9162327f18c50afc6364efe951eb85113653d1a
Content-Type: application/x-www-form-urlencoded
Content-Length: 274

PACKET2 (Client to Server):
Ôò¡          ÿÿ     i [Jh H  H   ¬ÆÙ? !p6kS E :M@ ¬|ä
#I

É
'#'Fè^mìU!Pü ü¸   <request><setAttribute hostName="{ServerfullURL}" hostPort="{ServerPort}" objectName="jde:instanceName={instance},targetType=webserver,metricName=user_manager,metricType=runtime" attribute="loginDisabledMessage" value=""></setAttribute></request>

PACKET3 (Server to Client):
Ôò¡          ÿÿ     i [JR ø   ø    !p6kS ¬ÆÙ? E  ê@ }âk

É
#I#'
'ìU!Fè_Pý#2  HTTP/1.1 200 OK
Date: Mon, 13 Jul 2009 21:00:26 GMT
Server: Oracle Containers for J2EE
Connection: close
Cache-Control: no-cache
Pragma: no-cache
Expires: Mon, 04 Dec 1999 21:29:02 GMT





0
 
altquarkAuthor Commented:
So, I'm now going through what I just posted (its good to get everything into the open)...and it seems that the packet formed by wget isn't exactly the same as the packet that IE is creating.

So, how do I get the packet to be EXACTLY the same ??!

Big differences that I see :
1. POST /manage/ajax HTTP/1.1 - can wget do HTTP1.1 ?
2. Accept-Language: en-us & Cache-Control: no-cache - can these be passed through ?
3. Content-Type: text/xml; charset=UTF-8 - this seems to be the biggy.  How do I change "content type"?
4. Referer: - do I need to put this in ?
5. Accept-Encoding: gzip, deflate - do I need to send this ?
6. Connection: Close - how do I do this ?

Thankyou for your advice.  I'm still working on this as well, using all the MAN pages I can get my hands on !
0
 
altquarkAuthor Commented:
I worked it out !!!  Yay !

Perserve and you shall wget the light !

I needed to add  :

--header="Content-Type: text/xml; charset=UTF-8"

to my wget - and lo and behold....it works !

Thankyou for your help anyway - I'll award you the points !
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now