Jump to content

InetRead returns hex?

Recommended Posts

I'm using InetRead to access a machine's ID on the amazon ec2 service. 


to access the string containing the machine's ID I'm using the line:

$instanceID = InetRead("",4)


$instanceID = StringLeft($instanceID,10) ; use the first ten characters


I think the "4" option in the InetRead function call should force ASCII format, but it must be struggling. 


The first ConsoleWrite returns: i-aa0fa69e (which is the properly formatted machine ID)

and the second ConsoleWrite returns: 0x692D6161


which appears to be the hex equivalent of the original string.


Does any body know how I can force the $instanceID variable to be an ASCII string?


This one is really confusing me




Edited by adamchapman
Link to comment
Share on other sites

Found a solution, although fairly long-winded:

ocal $hDownload = InetGet("","localID.txt",4,1)
ConsoleWrite("reading ID..." & @CRLF)
Until InetGetInfo($hDownload, 2) ; Check if the download is complete.

InetClose($hDownload) ; Close the handle to release resources.

; Now read that file in ASCII:
$Localidf=FileOpen("localID.txt", 0); read mode, no write permission LOCAL ID FILE
$instanceID = FileReadLine($LocalIDf, 1)

Writing the page text to a file with InetGet while forcing ASCII in the INetGet options, than reading the file back works fine. Strange how InetRead didn't act the same way though

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...