Skip to content
⌘ NSIS Forum Archive

read a text file from internet and insert in variable

34 posts

r2du-soft#

read a text file from internet and insert in variable

hi
how can read a text file from internet (from address) and show insert that in variable and show that with MessageBox?

i use from this command for do it:

inetc::get /NOCANCEL /SILENT "http://google.com/File.txt" "$EXEDIR\File.txt" /end
FileOpen $4 "$EXEDIR\File.txt" r
FileRead $4 $1
FileClose $4
MessageBox MB_OK "$1"

i want my text file text direct write in variable.
Something like this:

inetc::get /NOCANCEL /SILENT "http://google.com/File.txt" $1 /end
MessageBox MB_OK "$1"
Thanks
jpderuiter#
Have you tried the NsisUrlLib plugin?
However, this plugin is rather old, so I'd recommend to stay with your inetc solution.
r2du-soft#
i use NsisUrlLib but not give answer.
inetc is good command but i need Direct reading value in the variable 😢
Anders#
You already have a working solution. If you read the INetC docs you see that it only supports writing to a file.
r2du-soft#
but i looking for a better way.
Is not there any possibility to do this (Direct reading value in the variable) ?
r2du-soft#edited
Originally Posted by Afrow UK View Post
Sure there is, you just need to write the code 🙂

Stu
for guide me:What plug-in should I use?
r2du-soft#
Originally Posted by Afrow UK View Post
You need to write a plug-in or modify inetc.

Stu
I tried but did not succeed to do. 🙁
r2du-soft#
Friends, if I did not need any help do not question any time at this location! Because I knew And I had no problem!
Now I need some help,i want of yours Hurry to help me.
Thanks
r2du-soft#
Originally Posted by Afrow UK View Post
Download the file, read the value and delete the file?
Stu
I am using this method.
It is a good idea,But can bypass this method! 🙂 and edit that file.
Best way this is read file directly in variable
Anders#
Originally Posted by r2du-soft View Post
It is a good idea,But can bypass this method! 🙂 and edit that file.
Best way this is read file directly in variable
Someone could use a debugger and read/edit the variable directly, it is easy, just do "bp inetc!get", write down the address of the variables and step out of the function (if it was possible to read into a variable). Or someone could just sniff the traffic with Fiddler/Wireshark/whatever to read the number...
Afrow UK#
I have uploaded a new build of the inetc plug-in which has a /TOSTACK switch (see Examples/Inetc/ToStack.nsi).

Stu
r2du-soft#
Originally Posted by Afrow UK View Post
I have uploaded a new build of the inetc plug-in which has a /TOSTACK switch (see Examples/Inetc/ToStack.nsi).

Stu
i'm really really thanks Afrow UK
my problem solved,thanks my teacher
r2du-soft#
hi Masters
i have problem with inetc plug-in (ToStack.nsi) in windows 10 beta!
ToStack car read file from net and show me that text lenght but not show that text in msgbox!
if There is a way to solve this problem?
Anders#
Originally Posted by r2du-soft View Post
hi Masters
i have problem with inetc plug-in (ToStack.nsi) in windows 10 beta!
ToStack car read file from net and show me that text lenght but not show that text in msgbox!
if There is a way to solve this problem?
Example code? Example URL?

Does it only happen on Windows 10?
Anders#
Originally Posted by r2du-soft View Post
i'm really sorry
my nsis program in windows 10 was a problem,i solved that.
Are you going to share with us what the problem really was? It might help someone in the future...
r2du-soft#
really i don't know,compiler compile my code and give me a exe file,i can run that exe file,exe file can't download value from internet and when download value show me a error!
i download again Inetc plugins and replace "Inetc\Unicode\Plugins" from download folder plugins to "x86-unicode" folder and replace "Inetc\Plugins" from download folder plugins to "x86-ansi" and again compile my code,after run i see program good worked and download and show me that value!
i think my .dll file first was corrupted.
after do this works my problem solved,This strange for me...!!!!
r2du-soft#
i can't read the Persian text from file on internet and shown that

i use the code:

Unicode true

Section
inetc::get /NOCANCEL /TOSTACK /SILENT "http://RoseSoftware.com/Text.txt" /end
Pop $0
Pop $1
MessageBox MB_OK "$1"
SectionEnd
in the Text.txt file format is unicode and text words is persian (farsi)


i see the textbox message:




must i see in text box : سلام
but i see this characters






.
r2du-soft#
i do not want write that text in file and after that read file from hdd and show that on messagebox
i want read string to stack and convert to UTF16LE before show!
how is possible?
r2du-soft#
if i use from ansi then all characters show sample this: ******??

when i use unicode true,if i type persian character in messagebox,The message is displayed successfully
sample this:
MessageBox MB_OK|MB_RIGHT|MB_RTLREADING "سلام"
but if i read a text file from internet with text characters "سلام" with INETC,then characters is Unreadable!
Anders#
/TOSTACKCONV works correctly for me in a ANSI installer. Ideally the file should not have a BOM.
r2du-soft#
Originally Posted by Anders View Post
/TOSTACKCONV works correctly for me in a ANSI installer. Ideally the file should not have a BOM.

also i test the /TOSTACKCONV in inetc plugin but not work!

i attach the text files:

test_Utf8_BOM.txt
test_Utf8_Without_BOM.txt
test_Unicode_BE_BOM.txt
test_Unicode_LE_BOM.txt

also attach the nsi file.


i thinks your system setting in Region is different!












if set the "current language for non-Unicode programs" to Persian (Iran) Then the messages show good.


But if change the "current language for non-Unicode programs" to english and restart pc then if test read the txt files,see message show Unreadable words



attach files edited
need9989#
Can use curl.exe to get internet file


nsExec::ExecToStack '$MainPath\curl "http://google.com/File.txt"' $0
pop $0
pop $1

messagebox MB_OK "$1"