Signalsoldier74b
MIS
I am trying to write a script that posts data to a form and gets information from the results of the post. Basicaly, I need the script to be able to post a Employee ID number to our company's website and then parse the email address and other important data from the resulting page.
The problem is that no matter what I try all I get back is the form, not the data that I should get when the form is submitted Below are two examples. The first one is the vbScript that I'm trying to write, and the second is a working Unix Shell script.
Please help me figure out why I don't get any results. (FYI, I was told by the Unix guy that the server requires a host name in the header for it to return data)
The problem is that no matter what I try all I get back is the form, not the data that I should get when the form is submitted Below are two examples. The first one is the vbScript that I'm trying to write, and the second is a working Unix Shell script.
Please help me figure out why I don't get any results. (FYI, I was told by the Unix guy that the server requires a host name in the header for it to return data)
Code:
Dim objFSO, TempOutputFile, strStdID
strStdID = "n002813"
TempOutputFile = "C:\Documents and Settings\N002813\Desktop\Results.htm"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set TempOutputFile = objFSO.CreateTextFile(TempOutputFile)
Dim objXMLHTTP, xml
Set xml = CreateObject("MSXML2.ServerXMLHTTP.4.0")
intContLen = Len("&query_type=sil_std_id&sil_std_id=" & strStdID & "&nl_lookup=Go")
xml.Open "POST", "[URL unfurl="true"]http://itrisk.jpmorganchase.com/secLiaisonLookup/sil_std_id.php",[/URL] False
xml.setRequestHeader "POST", "[URL unfurl="true"]http://itrisk.jpmorganchase.com/webold/secLiaisonLookup/sil_std_id.php?rewritten=1[/URL] HTTP/1.1"
xml.setRequestHeader "Host","Ino0w005"
xml.setRequestHeader "Accept","*/*"
xml.setRequestHeader "Accept-Language","en-us"
xml.setRequestHeader "Content-Type","application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]
xml.setRequestHeader "Accept-Encoding","gzip,deflate"
xml.setRequestHeader "User-Agent","Mozilla/4.0"
xml.setRequestHeader "Content-Length",intContLen
xml.setRequestHeader "Connection","close"
xml.Send "&query_type=sil_std_id&sil_std_id=" & strStdID & "&nl_lookup=Go"
strHeaders = xml.getAllResponseHeaders()
TempOutputFile.WriteLine(xml.responseText)
WScript.Echo(strHeaders)
Set xml = Nothing
Code:
#!/bin/sh
#
ID=$1
get_id(){
#This function will get a file off of our webserver when passed the following parameters.
#(OS, OSLEVEL, RELEASE, AND FILE (THIS IS OPTIONAL)) If you do not specify the file the
#URL will determine that its the base package. If a file is specified the server will
#look in its hash for the appropriate file and try to grab it.
#This function will return 1 if theres any errors and a 0 if all is good.
#This function REQUIRES that check_uuencode be called prior to calling this function.
ID=$1
FILE=$4
TLEN=`echo "&query_type=sil_std_id&sil_std_id=$ID&nl_lookup=Go" | wc -c | sed -e 's/ //g'`
(
sleep 2
echo "POST [URL unfurl="true"]http://itrisk.jpmorganchase.com/webold/secLiaisonLookup/sil_std_id.php?rewritten=1[/URL] HTTP/1.1"
echo "Host: $HOSTNAME"
echo "Accept: */*"
echo "Accept-Language: en-us"
echo "Content-Type:application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]
echo "Accept-Encoding: gzip,deflate"
echo "User-Agent: Mozilla/4.0"
echo "Content-Length: $TLEN"
echo "Connection: close"
echo ""
echo "&query_type=sil_std_id&sil_std_id=$ID&nl_lookup=Go"
echo
sleep 10
) |telnet itrisk.jpmorganchase.com 80 2>/dev/null | grep -i Email | awk -FEmail '{print $2}' | awk '{print $2}' | awk -F\< '{print $1}'
}
get_id $ID