willichan Posted February 15, 2011 Share Posted February 15, 2011 This is probably borderline whether it is really AutoIt related or not. I have used slightly modified versions of this func to send data to a web page using POST before, without any troubles. For some reason, I cannot make it work this time. Hopefully, I am just missing a typo somewhere. Func _SendPing() Local $servername = "myservername" Local $serverport = 80 Local $ipconnection = -1 Local $i, $r, $s, $t $t = "" For $i = 0 To (UBound($SysInfo, 1) - 1) $t &= "&" & $SysInfo[$i][0] & "=" & _UnicodeURLEncode($SysInfo[$i][1]) Next $s = "POST /feedback/callhome.php HTTP/1.1" & @CRLF $s &= "Host: " & $servername & ":" & $serverport & @CRLF $s &= "From: " & @UserName & "@" & @ComputerName & @CRLF $s &= "User-Agent: DataPull/2.0" & @CRLF ;let the server logs show that this is an automated entry rather than manually done $s &= "Content-Type: application/x-www-form-urlencoded" & @CRLF $s &= "Content-Length: " & StringLen($t) & @CRLF & @CRLF $s &= $t $ipconnection = TCPConnect(TCPNameToIP($servername), $serverport) $r = TCPSend($ipconnection, $s) Sleep(100) TCPShutdown() EndFunc ;==>_sendping _UnicodeURLEncode() is from Dhilip89's UDF $SysInfo is a 2 dimensional array in the form of ["variable_name", "data"]. variable_name coincides with form variables if the page were pulled up for manual data entry. My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 15, 2011 Share Posted February 15, 2011 Put in a debug line to display or log $s to a file just before it gets used in TCPSend(). That should allow you to see where it fails. You didn't mention any failing symptoms or indications. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
willichan Posted February 15, 2011 Author Share Posted February 15, 2011 Sorry, I should have included that to begin with.$s contains:POST /feedback/callhome.php HTTP/1.1Host: myservername:80From: userlogin@usermachineUser-Agent: DataPull/2.0Content-Type: application/x-www-form-urlencodedContent-Length: 1586&OSType=WIN32_NT&OSVersion=WIN_XP&OSBuild=2600&OSServicePack=Service%20Pack%203&IEVer=6.0.2900.5512(confidential information stripped out. Actual content section confirmed to be 1586 characters.)The web page only returns the date/time the information was received, whether it succeeded or not. The only indication I have whether the POST worked or not is to run the reports for the database, and see if the information is there. So far, I have not been able to make it work for this page.This is an old internal web page that a client has, that was set up to make their inventory process easier. {{{re-emphasize OLD}}}I am not being given any control or access to the web server (I think someone is trying to hold onto a "perceived" job security), so I am trying to automate, as much as possible, the inventory process on the client side, and inject the data into the server. Since I want this to run silently with the login script, and since I don't care about what the page returns, I am using POST rather than trying to actually automate the page. I also want the server logs to show how much more/better data is being collected via my script than by the old manual inventory process. My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
trancexx Posted February 16, 2011 Share Posted February 16, 2011 Do you call TCPStartup before that function? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
willichan Posted February 16, 2011 Author Share Posted February 16, 2011 Do you call TCPStartup before that function? . . . after the repeated sound of a head banging on a desk . . .I knew it had to be some simple thing I left out.Thanks My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now