need help with httprequest and parsing info

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

need help with httprequest and parsing info

Post by idiot » Sun Feb 22, 2009 6:17 am

what im trying to do is check ip of my computer and compare that info with and ip saved to my web pages logfile and see if they have visited my thank you page and to check current date and see if its been more then say 30 days since thy visited my thank you page so basically if the ip matches check to see if is is thankyou page and if its been more then 30 days and if all 3 of these are correct then the program will run if not then program ends
so if ip matches and page has been visited and its been less then 30 days run program else end
im totally confused please help if i get this figured out i can buy the full version of macroscheduler with compiler
Last edited by idiot on Mon Mar 02, 2009 9:53 pm, edited 1 time in total.
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sun Feb 22, 2009 3:41 pm

Without going to the links, I think we could comfortably say this can be done with Macro Scheduler.

You will probably get more help if you provide the samples of the logs and files directly in your posting, rather than providing links to other pages.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

heres a copy of log file

Post by idiot » Sun Feb 22, 2009 7:17 pm

deleted
Last edited by idiot on Mon Mar 02, 2009 9:54 pm, edited 1 time in total.
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Mon Feb 23, 2009 2:31 am

Still not clear, but you could use RegExpression to save those lines with "GET /thank you" and parse out the IP and the date from those lines:
71.14.155.168 - - [21/Feb/2009:22:13:42 -0800] "GET /thankyou

You can now use MidString to get the IP, and the date.

You can then remove all lines that are over 30 days, for example.

The result is a list of IPs that have visited the thank you page in the last 30 days.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

this dosent work but maybe this helps show what i want to do

Post by idiot » Mon Mar 02, 2009 6:14 pm

Code: Select all

///ok here is where i get ip of my computer
Let>HTTP_TIMEOUT=5
HTTPRequest>http://checkip.dyndns.org,,GET,,HTMLResponse
Position>:,HTMLResponse,1,StartPos
Add>StartPos,2
Position><HTMLResponse>Endpos,1
MidStr>HTMLResponse,StartPos,EndPos,YourIP

///and here is where i get information from the website
HTTPRequest>http://customgameauto.com/logs/access.log,,get,info,strHTML,,,,

///and here is where i should parse the data to get ip address
///what im trying to do is compare info with YourIP to see if ip
///on computer matches one in log file
if>info=YourIP
goto>grant
else>
goto>deny
endif
label>grant
Message>access granted
endif
label>deny
Message>access denied


if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Mar 02, 2009 6:35 pm

So, just use the Position command. Pos returns the position of one string inside another. If it does NOT exist it returns zero. So if it DOES exist you get a value greater than zero. So:

Code: Select all

///ok here is where i get ip of my computer
Let>HTTP_TIMEOUT=5
HTTPRequest>http://checkip.dyndns.org,,GET,,HTMLResponse
Position>:,HTMLResponse,1,StartPos
Add>StartPos,2
Position><HTMLResponse>Endpos,1
MidStr>HTMLResponse,StartPos,EndPos,YourIP

///and here is where i get information from the website
HTTPRequest>http://customgameauto.com/logs/access.log,,get,info,strHTML,,,,

Pos>YourIP,strHTM,1,p
If>p>0
  Goto>grant
Endif
This simply says if YourIP is *anywhere within strHTML* goto Grant.

To reiterate. This simply looks to see if YourIP is SOMEWHERE INSIDE strHTML. It does not care where or how many times. Just whether or not it exists somewhere in the log file.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

Post by idiot » Mon Mar 02, 2009 6:48 pm

getting error in line 6 and its not working its just going to denied and my ip is in the file
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Mar 02, 2009 6:57 pm

That's this line, copied from YOUR post:

Position>Endpos,1

It's wrong. But I don't know what it is meant to be as I copied it from your post. I think it got mangled by the forum (always worth turning off HTML and Smilies). But since it's YOUR code you should already have the original in your script. MY code was only the last 4 lines.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

Post by idiot » Mon Mar 02, 2009 7:11 pm

ahh ok this works now your right
ok now that i got the basic http down
how do i detect line that ip was found on so i can use that line for other data like /thankyou
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Mar 02, 2009 7:17 pm

idiot wrote:ahh ok this works now your right
ok now that i got the basic http down
how do i detect line that ip was found on so i can use that line for other data like /thankyou
Ah, so now your requirements change. That is different from just knowing whether the IP is in the file.

Here's a way to see what line it's on:

Code: Select all

//Loop through all lines:
Separate>strHTML,CRLF,lines
Let>k=0
Repeat>k
  Let>k=k+1
  Let>this_line=lines_%k%
  //see if YourIP is in this_line
  Pos>YourIP,this_line,1,pline
  If>pline>0
     MessageModal>%YourIP% found on Line: %k%
  Endif
Until>k=lines_count
This simply looks in ALL lines. You could stop once found, or maybe you want to create an array of line numbers for all lines it's found on. You may want to parse the line further.

I expect you'll come back with more detailed requirements next ;-)
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

more detailed requirements 8-P

Post by idiot » Mon Mar 02, 2009 7:29 pm

ok so now i can get line number how do i use httprequest to search specific line?like once ive got the line that has the ip address then search that line for more data and if failed go to next next line search for ip again etc
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

Post by idiot » Mon Mar 02, 2009 8:48 pm

bump
Last edited by idiot on Mon Mar 02, 2009 9:14 pm, edited 1 time in total.
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

Post by idiot » Mon Mar 02, 2009 9:11 pm

nvm figured it out thanks for the help
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts