12 Replies - 4635 Views - Last Post: 23 May 2012 - 05:52 AM Rate Topic: -----

#1 Dodo8  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 21-May 12

Question: Creating a program that gets the biggest Revision number?

Posted 21 May 2012 - 09:45 AM

Hello! I like programming in Wikia and .bat files. I also use C++ 11 Beta. The Wiki projects and images I am taking from servers of the game in good scopes. I wanted to know how to get latest Revision numbers so I can get the newest things. I don't know C++ language so... This is one of the links: https://empire-s.ass...ameSettings.xml . You can see the old number (58370). I want to get the biggest possible number. Any help please?

I have a friend that is porgramming Linux. He gave me this advice:
#! /bin/sh -

# last known version
flash_vers="$1"
if [ -z "$flash_vers" ]
then
flash_vers=52767
fi
max_flash_vers=$(($flash_vers + 400))
while [ "$flash_vers" -lt "$max_flash_vers" ]
do
if [ ! -d "$flash_vers" ]
then
good=`wget -q -O - http://empire-zc.static.zgncdn.com/assets/"$flash_vers"/gameSettings.xml | wc -c`
if [ -n "$good" -a "$good" -gt 0 ]
then
echo "Good version: $flash_vers"
get_flash "$flash_vers"
fi
fi
flash_vers=$(($flash_vers + 1))
done


Maybe is helpfull for your advices?

Is This A Good Question/Topic? 0
  • +

Replies To: Question: Creating a program that gets the biggest Revision number?

#2 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3662
  • View blog
  • Posts: 11,466
  • Joined: 05-May 12

Re: Question: Creating a program that gets the biggest Revision number?

Posted 21 May 2012 - 11:45 AM

Yikes! I'm surprised the server owner isn't locking you guys out. It looks like his script just keeps on doing gets until it fails to get the resource. If somebody is managing the Wiki project, there should be a page that you can query that has all the latest revision numbers, or has all the latest revisions of the resources. It would be insane if everybody had to poll the server trying to find the latest copy.
Was This Post Helpful? 0
  • +
  • -

#3 baavgai  Icon User is online

  • Dreaming Coder
  • member icon

Reputation: 5929
  • View blog
  • Posts: 12,851
  • Joined: 16-October 07

Re: Question: Creating a program that gets the biggest Revision number?

Posted 21 May 2012 - 12:56 PM

That's a big ole XML file and you're just grabbing it and getting a word count? I'm not sure how this has any value.

If you know what XML element you're interested in, you can stop reading after you get it. Also, to be nice, you can look at the HTTP header for a revision date. If it hasn't changed since the last time you checked, then don't even bother with the download.
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6107
  • View blog
  • Posts: 23,659
  • Joined: 23-August 08

Re: Question: Creating a program that gets the biggest Revision number?

Posted 21 May 2012 - 02:52 PM

What the hell? If all you want to do is check that the directory name there is valid, move to curl and use

#!/usr/bin/env bash

RESULT=$(curl -I -s -w %{http_code} http://empire-zc.static.zgncdn.com/assets/52767/gameSettings.xml -o /dev/null)
if [ $RESULT -eq 200 ]; then
	echo "OK"
else
	echo "Fail"
fi


so you're not uselessly beating the hell out of the server.

Moved to Other Languages, as other than a mention of C++, all I see is a Bash script.
Was This Post Helpful? 1
  • +
  • -

#5 Dodo8  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 21-May 12

Re: Question: Creating a program that gets the biggest Revision number?

Posted 22 May 2012 - 01:47 AM

Thanks all very much :rolleyes: .
Was This Post Helpful? 0
  • +
  • -

#6 Dodo8  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 21-May 12

Re: Question: Creating a program that gets the biggest Revision number?

Posted 22 May 2012 - 01:55 AM

View PostJackOfAllTrades, on 21 May 2012 - 02:52 PM, said:

What the hell? If all you want to do is check that the directory name there is valid, move to curl and use

#!/usr/bin/env bash

RESULT=$(curl -I -s -w %{http_code} http://empire-zc.static.zgncdn.com/assets/52767/gameSettings.xml -o /dev/null)
if [ $RESULT -eq 200 ]; then
	echo "OK"
else
	echo "Fail"
fi


so you're not uselessly beating the hell out of the server.

Moved to Other Languages, as other than a mention of C++, all I see is a Bash script.


It says there were build errors. I think I don't select the right Project type?
Was This Post Helpful? 0
  • +
  • -

#7 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6107
  • View blog
  • Posts: 23,659
  • Joined: 23-August 08

Re: Question: Creating a program that gets the biggest Revision number?

Posted 22 May 2012 - 03:27 AM

That's Bash, script kiddie, not C or C++. And it's simply a replacement for the obnoxious (even though the target is Zynga, so I'm not crying in my oatmeal) wget call in the original.

Doing this in a low-level language like C/C++ is folly. Much better to be done in a scripting language. You're not going to get someone to write you C/C++ code to do this, which is what your idea of programming probably is...get someone else to do it for you.
Was This Post Helpful? 0
  • +
  • -

#8 baavgai  Icon User is online

  • Dreaming Coder
  • member icon

Reputation: 5929
  • View blog
  • Posts: 12,851
  • Joined: 16-October 07

Re: Question: Creating a program that gets the biggest Revision number?

Posted 22 May 2012 - 04:00 AM

I'd also use curl:
[baavgai#DIC]$ curl -I http://empire-s.assets.zgncdn.com/assets/58370/gameSettings.xml
HTTP/1.1 200 OK
x-amz-id-2: R+53q4FoxSUDxsYKsim7t/jippFcVCCvArDrFEP/8fq+mysqc+teUAjpzWwRdK5Y
x-amz-request-id: BFEEADEA39653CBC
Accept-Ranges: bytes
Content-Type: text/xml
Server: AmazonS3
Age: 307651
Date: Mon, 21 May 2012 19:46:28 GMT
Last-Modified: Fri, 18 May 2012 19:35:16 GMT
Expires: Fri, 17 May 2013 15:35:04 GMT
Content-Length: 5056465
Via: 1.1 localhost.localdomain

[baavgai#DIC]$ curl -I http://empire-s.assets.zgncdn.com/assets/58370/gameSettings.xm
HTTP/1.1 403 Forbidden
x-amz-request-id: BAA9A94CFCF90D6D
x-amz-id-2: BqOyORsmmmh08AgDoGkLyDDD/SROB+BFBdImclz9BEFGm6+M9lTzw9a8yXzJ1+VX
Content-Type: application/xml
Date: Tue, 22 May 2012 10:46:38 GMT
Server: AmazonS3
Age: 0

[baavgai#DIC]$



What do we know? The first is the result of file in question. The second is an intentional call to something that isn't there. We also know they're using Amazon... unimportant for this.

Perhaps:
[baavgai#DIC]$ curl -s -I http://empire-s.assets.zgncdn.com/assets/58370/gameSettings.xml | grep '^Last-Modified:'
Last-Modified: Fri, 18 May 2012 19:35:16 GMT
[baavgai#DIC]$ curl -s -I http://empire-s.assets.zgncdn.com/assets/58370/gameSettings.xm | grep '^Last-Modified:'
[baavgai#DIC]$



Perfect. I'm unlikely to get a Last-Modified on a buggered response. So, if I take the result and compare it to what I have, I know if I'm up to date or not.

You want to do that in C? Well, there is libcurl. Have at.
Was This Post Helpful? 0
  • +
  • -

#9 Dodo8  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 21-May 12

Re: Question: Creating a program that gets the biggest Revision number?

Posted 22 May 2012 - 09:42 AM

Sorry it's my mistake. I forgot to tell you that I'm using Windows 7... not Linux. And JackOfAllTrades, I'm really a kiddie. I haven't finished 6th grade yet :dozingoff: . So if you can please help me, if I use C++ of C# what should I select? "win32 Console Application" , "Native Unit Test Project", etc?
Was This Post Helpful? 0
  • +
  • -

#10 Dodo8  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 21-May 12

Re: Question: Creating a program that gets the biggest Revision number?

Posted 22 May 2012 - 10:33 AM

View Postbaavgai, on 22 May 2012 - 04:00 AM, said:

I'd also use curl:
[baavgai#DIC]$ curl -I http://empire-s.assets.zgncdn.com/assets/58370/gameSettings.xml
HTTP/1.1 200 OK
x-amz-id-2: R+53q4FoxSUDxsYKsim7t/jippFcVCCvArDrFEP/8fq+mysqc+teUAjpzWwRdK5Y
x-amz-request-id: BFEEADEA39653CBC
Accept-Ranges: bytes
Content-Type: text/xml
Server: AmazonS3
Age: 307651
Date: Mon, 21 May 2012 19:46:28 GMT
Last-Modified: Fri, 18 May 2012 19:35:16 GMT
Expires: Fri, 17 May 2013 15:35:04 GMT
Content-Length: 5056465
Via: 1.1 localhost.localdomain

[baavgai#DIC]$ curl -I http://empire-s.assets.zgncdn.com/assets/58370/gameSettings.xm
HTTP/1.1 403 Forbidden
x-amz-request-id: BAA9A94CFCF90D6D
x-amz-id-2: BqOyORsmmmh08AgDoGkLyDDD/SROB+BFBdImclz9BEFGm6+M9lTzw9a8yXzJ1+VX
Content-Type: application/xml
Date: Tue, 22 May 2012 10:46:38 GMT
Server: AmazonS3
Age: 0

[baavgai#DIC]$



What do we know? The first is the result of file in question. The second is an intentional call to something that isn't there. We also know they're using Amazon... unimportant for this.

Perhaps:
[baavgai#DIC]$ curl -s -I http://empire-s.assets.zgncdn.com/assets/58370/gameSettings.xml | grep '^Last-Modified:'
Last-Modified: Fri, 18 May 2012 19:35:16 GMT
[baavgai#DIC]$ curl -s -I http://empire-s.assets.zgncdn.com/assets/58370/gameSettings.xm | grep '^Last-Modified:'
[baavgai#DIC]$



Perfect. I'm unlikely to get a Last-Modified on a buggered response. So, if I take the result and compare it to what I have, I know if I'm up to date or not.

You want to do that in C? Well, there is libcurl. Have at.


Thanks. I will try libcurl if anyone can't help with C or C++. :dontgetit:
Was This Post Helpful? 0
  • +
  • -

#11 baavgai  Icon User is online

  • Dreaming Coder
  • member icon

Reputation: 5929
  • View blog
  • Posts: 12,851
  • Joined: 16-October 07

Re: Question: Creating a program that gets the biggest Revision number?

Posted 22 May 2012 - 11:26 AM

Now wait, before you also said C#... If you're doing standard .NET programming, there's built in stuff you can use. e.g. http://msdn.microsof...=vs.110%29.aspx

If you're using plain old C and can't get curl to work, it's actually not that hard to get HTTP response text with a few socket calls. You should find tons of socket code on the net. Even for windows.

No one here is just going to do it for you. You can find example code all over the place to grab web pages in C and C++. If YOU are writing a program then we'd love to help. Show the code. ( And probably start a new thread if you ever do write any code. )
Was This Post Helpful? 1
  • +
  • -

#12 Dodo8  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 21-May 12

Re: Question: Creating a program that gets the biggest Revision number?

Posted 22 May 2012 - 11:51 PM

View Postbaavgai, on 22 May 2012 - 11:26 AM, said:

Now wait, before you also said C#... If you're doing standard .NET programming, there's built in stuff you can use. e.g. http://msdn.microsof...=vs.110%29.aspx

If you're using plain old C and can't get curl to work, it's actually not that hard to get HTTP response text with a few socket calls. You should find tons of socket code on the net. Even for windows.

No one here is just going to do it for you. You can find example code all over the place to grab web pages in C and C++. If YOU are writing a program then we'd love to help. Show the code. ( And probably start a new thread if you ever do write any code. )


Thanks. I know a guy that downloaded all the images using .NET framework. Maybe it helps with my problem too. -.-

I think I found something: http://msdn.microsof...(v=vs.110).aspx If I'll need help with the program I'll tell in a new post thanks.
Was This Post Helpful? 0
  • +
  • -

#13 baavgai  Icon User is online

  • Dreaming Coder
  • member icon

Reputation: 5929
  • View blog
  • Posts: 12,851
  • Joined: 16-October 07

Re: Question: Creating a program that gets the biggest Revision number?

Posted 23 May 2012 - 05:52 AM

The point of a new post would be to show the code you're working on and where you're stuck. I saw your post; it has no real context and is not your code!

You aren't working on code, you're trying to make the internet write it for you. I'm afraid we don't do that here.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1