Jump to content

OverloadUT

Active Members
  • Posts

    46
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

OverloadUT's Achievements

Seeker

Seeker (1/7)

2

Reputation

  1. Those tail functions use _FileCountLines() which has to read the entire file in to memory. Once again, I cannot have it do that. The solutions presented by gafrost and randallc do not read the entire file in to memory, which is exactly what I need. I'll use qafrost's because it's a very small amount of code and all I need to do is read a file from a particular byte forward, not write to the file. Thanks everyone! Edit: Actually, the "scripting.filesystemobject" method used in gafrost's solution takes a while to seek far in to a file. I tested it seeking 100mb in to a 200mb file, and it took a good 3 seconds to execute. The _APIFile functions in randallc's solution works perfectly - seeking 100mb in only takes a few ms. Thanks!
  2. Thank you gafrost, that's exactly what I need! In case you're curious, my AutoIt program serves as the "bridge" between Civilization 4 and my civstats.com website. The AutoIt program will need to read from a log file created by a Civ4 python script and upload only the new log items to the webserver every time it changes. This log file could potentially become very large so just remembering the last byte I stopped at on the last upload is seems like the most logical way of doing it. Every couple seconds I check to see if the log file has grown, and if it has I start reading any bytes starting after the last byte I read.
  3. _FileCountLines() is simply a UDF that does this: Return StringLen(StringAddCR(FileRead($sFilePath, $N))) - $N + 1 ; $N is the size of the file Therefore, it has to read the entire file in to memory with the "FileRead()" call. I need to avoid doing that.
  4. Yes, both of those solutions would accomplish the goal of reading part of the file, but the fundamental problem is the fact that both of them require reading the entire file in to memory. As I said, my file could be 30mb, so that would be a huge amount of memory to use every 5 seconds. The file system allows you to "seek" to a particular byte and only read the bytes you want to, but all of the AU3 functions seem to read the entire file in to memory...
  5. I am in need of reading a file starting from a particular byte. I do not want to read the entire file in to memory and then scan it that way, because this file could be up to 30 megs, and I need to read it every 5 seconds. I looked through the help file and I couldn't find any file read functions that let you seek to a particular byte and read from there. Does this exist?
  6. In both of your examples, you're declaring the variable AFTER you call "IsDeclared" so it's functioning exactly as expected. If this just a snippit of your code? If it is, post the whole thing, or at least the entirety of an example so we can see.
  7. Well, you can read the cookies sent by the server using these functions, but I currently don't have a way of sending custom headers with a get or post request - that's something I'll need to add. I might create special cookie handling functions as well.
  8. Google actually does all of its searches as GET requests, not POST requests. This is so that you can link a page of results and actually have it work. In that case, to do a google search, you would want to do this: $host = "www.google.com" $page = "/imghp" $vars = "hl=en&tab=wi&q=" $searchterm = "porche" $url = $page&"?"&_HTTPEncodeString($vars&$searchstring) $socket = _HTTPConnect($host) $get = _HTTPGet($host,$url,$socket) $recv = _HTTPRead($socket,1) ConsoleWrite("Data received:"&@CRLF$recv[4]&@CRLF) Any variables after the question mark need to be HTTP Encoded, which is why I put the "vars" in a separate variable from the page.
  9. Ironically, B3TA_SCR1PT3R's method is in some ways more random, because it contains unpredictable entropy. Food for thought.
  10. Thank you everyone for the kind words. If anyone actually gives it a try, I'd love to hear how it works for them. This website was my main source. Well, that and a LOT of trial and error.
  11. That code will work, but the output will be the raw packets as opposed to the actual data of the response. In the case of a chunked response, it would be a real pain to write a parser... ... a pain that I already went through, so you shouldn't have to! I recommend checking out my HTTP UDF's - one of the features is that you can set the User-Agent.
  12. I am working on a fairly large project and a big part of it is an AutoIt application that uploads a lot of data to a PHP script. For a while I was using INetGet and submitting all my data as GET variables in the URL. However, the amount of data to upload got too big (over 1000 characters) and the INetGet function started to fail. I also hated that INetGet ONLY works if the webserver responds with "200 OK" - There is no way to tell the difference between a 404 error and simply not being able to connect to the server in the first place. So I write this library of UDF's. Basically, it's a fully compliant HTTP/1.1 client. It uses only the TCP functions; no DllCall needed here! I had a blast learning all about the HTTP protocol and how to use it. Advantages over INetGet: The data is downloaded right in to variables instead of to files. You can of course then write this data to a file if you wish. You can read all of the headers supplied by the webserver. You can get the HTTP Response Code from the webserver. When it failes, you know exactly what failed instead of having to guess. ; =================================================================== ; HTTP UDF's ; v0.5 ; ; By: Greg "Overload" Laabs ; Last Updated: 07-22-06 ; Tested with AutoIt Version 3.1.1.131 ; Extra requirements: Nothing! ; ; A set of functions that allow you to download webpages and submit ; POST requests. ; ; Main functions: ; _HTTPConnect - Connects to a webserver ; _HTTPGet - Submits a GET request to a webserver ; _HTTPPost - Submits a POST request to a webserver ; _HTTPRead - Reads the response from a webserver ; =================================================================== I consider this UDF package to be a "beta" and that's why I call it version 0.5. However, I would love people to give it a try and tell me how it works for them. I have done extensive testing and I think I have the parser working perfectly. I plan on improving this library. It's possible that I might change the way the functions work (I don't think the _HTTPConnect function is necessary; I could move that functionality right in to the Get or Post functions.) To Do: Add a function that downloads the data right to a file. You might not want to download a 10 meg file in to memory before saving it to a file.Add a method to get the progress of the download. This will probably be in the form of a callback function, if that's possible in AutoIt.Add the ability to automatically follow "Location:" headers. Currently you'd have to do it manually.Other things I can't think of!Post #25 For Updated functions to work with current AutoIt versions.
  13. ... I knew it was something simple. And I've been using regular expressions for years too. I am ashamed. Thanks!
  14. Okay, I've been banging my head against this for at least an hour now. I'm sure it's something simple, but I can't for the life of me figure it out. I wanted to check here before I submit it as a bug. $data = "|pbupload:test|anothervar:test2|" $regex = StringRegExp($data, "|error:([^|:]+)|", 1) ConsoleWrite(@error&@CRLF&@extended&@CRLF) That outputs: 0 1 WHY? The pattern should mean: Literal string "|error:" followed by 1 or more characters that are not "|" or ":" (and capture it as a group) and then the literal string "|" That pattern should NOT match the test string because "error:" is not in it! Please tell me I'm going crazy and missing something simple...
×
×
  • Create New...