Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Help with saving with a dif name.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Micah
Grandmaster Cheater
Reputation: 1

Joined: 30 Mar 2007
Posts: 833

PostPosted: Tue Nov 18, 2008 7:41 pm    Post subject: Help with saving with a dif name. Reply with quote

I have a batch script, it does a find, then saves the results as test.txt
What would I have to do to get it to save as a slightly dif name like test1.txt, so it doesn't overwrite my other file.
Code:
ipconfig/all> \test.txt


I would really like an example.

_________________
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 475

Joined: 09 May 2003
Posts: 25974
Location: The netherlands

PostPosted: Tue Nov 18, 2008 8:10 pm    Post subject: Reply with quote

I could be completely wrong and just a guess here, but have you ever tried changing test.txt to test1.txt ?

Also, if you don't want overwriting but appending, change > to >>

_________________
Tools give you results. Knowledge gives you control.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Micah
Grandmaster Cheater
Reputation: 1

Joined: 30 Mar 2007
Posts: 833

PostPosted: Tue Nov 18, 2008 9:33 pm    Post subject: Reply with quote

Dark Byte wrote:
Also, if you don't want overwriting but appending, change > to >>

Thanks, that is what I wanted, I didn't want it to overwrite, because I will be running the script on many different computers, so I don't want it to overwrite the existing one.

Edit: www.whatismyip.com shows a different IP than ipconfig.
Is it possible to write a program that can get the same results as the website, I want to find my internal and external ip.
Thanks `Micah

_________________
Back to top
View user's profile Send private message MSN Messenger
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Wed Nov 19, 2008 12:06 am    Post subject: Reply with quote

Mmm you could use telnet, although that can't be automated without some 3rd party software. Your best option is to download WGET. Example usage,
Code:
@echo off
FOR /F %%i IN ('wget http://whatismyip.org -O - -q') DO SET MyIP=%%i
>whatismyip.txt ECHO External IP Address: %MyIP%
Back to top
View user's profile Send private message
Micah
Grandmaster Cheater
Reputation: 1

Joined: 30 Mar 2007
Posts: 833

PostPosted: Wed Nov 19, 2008 8:13 am    Post subject: Reply with quote

Hmmmm would it be possible to write a script to navigate to the page and save the page as a text file?
_________________
Back to top
View user's profile Send private message MSN Messenger
SXGuy
I post too much
Reputation: 0

Joined: 19 Sep 2006
Posts: 3551

PostPosted: Wed Nov 19, 2008 9:04 am    Post subject: Reply with quote

Here you go, simple little program i wrote to grab any i.p address from whatismyip.com and save it to a text file in the same location as this file is ran from.

Ive included the exe and i have also pasted the source below.

Code:
#include <INet.au3>
FileWrite("I.P.txt",_INetGetSource ("http://www.whatismyip.com/automation/n09230945.asp" ))


EDIT: ive also included a localIP address capture just incase the website goes down sometimes.

Code:
#include <Inet.au3>
$PublicIP = _GetIP()
FileWrite("LocalIP.txt","Your IP Address is: " & $PublicIP)



The Extension 'rar' was deactivated by an board admin, therefore this Attachment is not displayed.


The Extension 'rar' was deactivated by an board admin, therefore this Attachment is not displayed.

Back to top
View user's profile Send private message
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Wed Nov 19, 2008 5:30 pm    Post subject: Reply with quote

Micah wrote:
Hmmmm would it be possible to write a script to navigate to the page and save the page as a text file?

Yeah, that is the main purpose of WGET.. you cannot automate this using the standard windows command line tools. Two choices remain, download an external tool, or abandon batch scripts and create your own executable.
Back to top
View user's profile Send private message
SXGuy
I post too much
Reputation: 0

Joined: 19 Sep 2006
Posts: 3551

PostPosted: Wed Nov 19, 2008 5:31 pm    Post subject: Reply with quote

So basically what i already supplied him with? Rolling Eyes
Back to top
View user's profile Send private message
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Wed Nov 19, 2008 5:34 pm    Post subject: Reply with quote

Indeed, though I don't think he understands it's not possible to do without an external tool. Razz
Back to top
View user's profile Send private message
SXGuy
I post too much
Reputation: 0

Joined: 19 Sep 2006
Posts: 3551

PostPosted: Wed Nov 19, 2008 5:37 pm    Post subject: Reply with quote

yeah i guess, i dont know of any way to automate it using a batch file only.
Back to top
View user's profile Send private message
Micah
Grandmaster Cheater
Reputation: 1

Joined: 30 Mar 2007
Posts: 833

PostPosted: Wed Nov 19, 2008 8:33 pm    Post subject: Reply with quote

I knew batch couldn't do it, I wanted to know what language could.

I wanted to know if it was possible, I have made a few things in C++ before, it is perfectly fine if I have to write something in C++.
I do need WAYYYY more knowlege of C++ though.... All I know is the easy stuff, and I don't know what #includes I have to have for alot of things....

Thanks for the example in C++.

_________________
Back to top
View user's profile Send private message MSN Messenger
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Wed Nov 19, 2008 10:50 pm    Post subject: Reply with quote

My apologies then.. your question wasn't very clear. The example SXGuy posted above was written for use with AutoIt, google "c++ whatismyip" for an implementation in c/c++ using sockets. You might want to try a socket class to simplify things, and you can find a good sockets guide here.
Back to top
View user's profile Send private message
SXGuy
I post too much
Reputation: 0

Joined: 19 Sep 2006
Posts: 3551

PostPosted: Thu Nov 20, 2008 3:27 am    Post subject: Reply with quote

Well considering Autoit is written in c++ but uses its own language to define its wrappers, pretty much anything it does can be back engineered to c++ again, just takes looking at the includes and recreating it.

So heres the two functions included in INET.au3 that i used, hopefully you can recreate it in c++

Code:
Function Name:    _GetIP()
; Description:      Get public IP address of a network/computer.
; Parameter(s):     None
; Requirement(s):   Internet access.
; Return Value(s):  On Success - Returns the public IP Address
;                   On Failure - -1  and sets @ERROR = 1
; Author(s):        Larry/Ezzetabi & Jarvis Stubblefield
;
;===============================================================================
Func _GetIP()
   Local $ip, $t_ip
   If InetGet("http://checkip.dyndns.org/?rnd1=" & Random(1, 65536) & "&rnd2=" & Random(1, 65536), @TempDir & "\~ip.tmp") Then
      $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp"))
      FileDelete(@TempDir & "\~ip.tmp")
      $ip = StringTrimLeft($ip, StringInStr($ip, ":") + 1)
      $ip = StringTrimRight($ip, StringLen($ip) - StringInStr($ip, "/") + 2)
      $t_ip = StringSplit($ip, '.')
      If $t_ip[0] = 4 And StringIsDigit($t_ip[1]) And StringIsDigit($t_ip[2]) And StringIsDigit($t_ip[3]) And StringIsDigit($t_ip[4]) Then
         Return $ip
      EndIf
   EndIf
   If InetGet("http://www.whatismyip.com/?rnd1=" & Random(1, 65536) & "&rnd2=" & Random(1, 65536), @TempDir & "\~ip.tmp") Then
      $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp"))
      FileDelete(@TempDir & "\~ip.tmp")
      $ip = StringTrimLeft($ip, StringInStr($ip, "Your ip is") + 10)
      $ip = StringLeft($ip, StringInStr($ip, " ") - 1)
      $ip = StringStripWS($ip, 8)
      $t_ip = StringSplit($ip, '.')
      If $t_ip[0] = 4 And StringIsDigit($t_ip[1]) And StringIsDigit($t_ip[2]) And StringIsDigit($t_ip[3]) And StringIsDigit($t_ip[4]) Then
         Return $ip
      EndIf
   EndIf
   SetError(1)
   Return -1
EndFunc   ;==>_GetIP



and

Code:
; Function Name:    _INetGetSource()
; Description:      Gets the source from an URL without writing a temp file.
; Parameter(s):     $s_URL = The URL of the site.
; Requirement(s):   DllCall/Struct & WinInet.dll
; Return Value(s):  On Success - Returns the source code.
;                   On Failure - 0  and sets @ERROR = 1
; Author(s):        Wouter van Kesteren.
;
;===============================================================================
Func _INetGetSource($s_URL, $s_Header = '')

   If StringLeft($s_URL, 7) <> 'http://' And StringLeft($s_URL, 8) <> 'https://' Then $s_URL = 'http://' & $s_URL

   Local $h_DLL = DllOpen("wininet.dll")

   Local $ai_IRF, $s_Buf = ''

   Local $ai_IO = DllCall($h_DLL, 'int', 'InternetOpen', 'str', "AutoIt v3", 'int', 0, 'int', 0, 'int', 0, 'int', 0)
   If @error Or $ai_IO[0] = 0 Then
      DllClose($h_DLL)
      SetError(1)
      Return ""
   EndIf

   Local $ai_IOU = DllCall($h_DLL, 'int', 'InternetOpenUrl', 'int', $ai_IO[0], 'str', $s_URL, 'str', $s_Header, 'int', StringLen($s_Header), 'int', 0x80000000, 'int', 0)
   If @error Or $ai_IOU[0] = 0 Then
      DllCall($h_DLL, 'int', 'InternetCloseHandle', 'int', $ai_IO[0])
      DllClose($h_DLL)
      SetError(1)
      Return ""
   EndIf

   Local $v_Struct = DllStructCreate('udword')
   DllStructSetData($v_Struct, 1, 1)

   While DllStructGetData($v_Struct, 1) <> 0
      $ai_IRF = DllCall($h_DLL, 'int', 'InternetReadFile', 'int', $ai_IOU[0], 'str', '', 'int', 256, 'ptr', DllStructGetPtr($v_Struct))
      $s_Buf &= StringLeft($ai_IRF[2], DllStructGetData($v_Struct, 1))
   WEnd

   DllCall($h_DLL, 'int', 'InternetCloseHandle', 'int', $ai_IOU[0])
   DllCall($h_DLL, 'int', 'InternetCloseHandle', 'int', $ai_IO[0])
   DllClose($h_DLL)
   Return $s_Buf
EndFunc   ;==>_INetGetSource




Dont be startled by all the code, remember in c++ its gonna be hell of alot shorter lol
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Thu Nov 20, 2008 5:00 am    Post subject: Reply with quote

ok, it's like this:

Micah, whatismyip.com shows your WAN ip (Global), which is how people use to trace you. but it is just a IP your Router (unless you're Wired) generates you (unless it's not being changed).

it is used to so the internet will identify you.

ipconfig shows your LAN ip (Local Network), which is just a stupid IP your network card generates you and that's how the Router (unless you're wired) identify you.
Back to top
View user's profile Send private message
SXGuy
I post too much
Reputation: 0

Joined: 19 Sep 2006
Posts: 3551

PostPosted: Thu Nov 20, 2008 5:47 am    Post subject: Reply with quote

Also remember that http://www.whatismyip.com/automation/n09230945.asp just displays your global i.p address as raw text.

So if you know of a way to save html or all text from a website to a text file, just use that link, it will only display your i.p and no other junk html code.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites