Old 14th July 2014, 10:10   #1
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
Question 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:

HTML Code:
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:

HTML Code:
inetc::get /NOCANCEL /SILENT "http://google.com/File.txt" $1 /end
MessageBox MB_OK "$1"
Thanks
r2du-soft is offline   Reply With Quote
Old 14th July 2014, 11:17   #2
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
Have you tried the NsisUrlLib plugin?
However, this plugin is rather old, so I'd recommend to stay with your inetc solution.
jpderuiter is offline   Reply With Quote
Old 14th July 2014, 11:53   #3
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
Unhappy

i use NsisUrlLib but not give answer.
inetc is good command but i need Direct reading value in the variable
r2du-soft is offline   Reply With Quote
Old 14th July 2014, 12:03   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
You already have a working solution. If you read the INetC docs you see that it only supports writing to a file.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 15th July 2014, 03:40   #5
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
but i looking for a better way.
Is not there any possibility to do this (Direct reading value in the variable) ?
r2du-soft is offline   Reply With Quote
Old 15th July 2014, 08:31   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Sure there is, you just need to write the code

Stu
Afrow UK is offline   Reply With Quote
Old 15th July 2014, 09:01   #7
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
Quote:
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?

Last edited by r2du-soft; 15th July 2014 at 10:10.
r2du-soft is offline   Reply With Quote
Old 15th July 2014, 09:18   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
You need to write a plug-in or modify inetc.

Stu
Afrow UK is offline   Reply With Quote
Old 15th July 2014, 12:17   #9
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
Quote:
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 is offline   Reply With Quote
Old 16th July 2014, 15:54   #10
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
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 is offline   Reply With Quote
Old 17th July 2014, 00:27   #11
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
Why is downloading to $pluginsdir first such a big problem?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 17th July 2014, 04:46   #12
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
Value Reads is a number.
i do not want user can find that file and edit that.
r2du-soft is offline   Reply With Quote
Old 17th July 2014, 07:23   #13
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Download the file, read the value and delete the file?

Stu
Afrow UK is offline   Reply With Quote
Old 17th July 2014, 07:33   #14
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
Quote:
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
r2du-soft is offline   Reply With Quote
Old 17th July 2014, 09:28   #15
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
Quote:
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...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 20th July 2014, 16:20   #16
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I have uploaded a new build of the inetc plug-in which has a /TOSTACK switch (see Examples/Inetc/ToStack.nsi).

Stu
Afrow UK is offline   Reply With Quote
Old 20th July 2014, 17:24   #17
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
Post

Quote:
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 is offline   Reply With Quote
Old 17th December 2014, 11:15   #18
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
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?
r2du-soft is offline   Reply With Quote
Old 17th December 2014, 12:42   #19
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
Quote:
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?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 19th December 2014, 10:24   #20
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
i'm really sorry
my nsis program in windows 10 was a problem,i solved that.
r2du-soft is offline   Reply With Quote
Old 19th December 2014, 14:27   #21
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
Quote:
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...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 20th December 2014, 21:21   #22
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
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 is offline   Reply With Quote
Old 13th September 2018, 21:11   #23
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
i can't read the Persian text from file on internet and shown that

i use the code:

HTML 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






.
Attached Thumbnails
Click image for larger version

Name:	2018-09-14_1-40-15.jpg
Views:	25
Size:	7.6 KB
ID:	53989  
r2du-soft is offline   Reply With Quote
Old 13th September 2018, 21:20   #24
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
You must use FileReadUTF16LE to read from a UTF-16LE text file.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 13th September 2018, 21:28   #25
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
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 is offline   Reply With Quote
Old 13th September 2018, 23:00   #26
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
If you are building as ANSI then you can add the /TOSTACKCONV parameter to InetC.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 14th September 2018, 14:09   #27
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
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:
HTML Code:
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!
r2du-soft is offline   Reply With Quote
Old 14th September 2018, 18:16   #28
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
/TOSTACKCONV works correctly for me in a ANSI installer. Ideally the file should not have a BOM.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 15th September 2018, 14:04   #29
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
Quote:
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
Attached Thumbnails
Click image for larger version

Name:	2018-09-15_18-27-27.jpg
Views:	29
Size:	71.2 KB
ID:	53995   Click image for larger version

Name:	2018-09-15_18-27-31.jpg
Views:	29
Size:	45.4 KB
ID:	53996   Click image for larger version

Name:	2018-09-15_18-27-34.jpg
Views:	29
Size:	80.0 KB
ID:	53997  
Attached Files
File Type: zip Read_Persian_Text.zip (1.5 KB, 3 views)
r2du-soft is offline   Reply With Quote
Old 15th September 2018, 16:37   #30
need9989
Junior Member
 
Join Date: Feb 2017
Posts: 3
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"
need9989 is offline   Reply With Quote
Old 15th September 2018, 17:09   #31
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,873
Quote:
Originally Posted by r2du-soft View Post
if set the "current language for non-Unicode programs" to Persian (Iran) Then the messages show good.
That is how ANSI works.

To support all languages on all computers you must use Unicode. I don't think there are any download plug-ins that will give you raw bytes or hex bytes on the stack you are stuck with downloading to a file to $pluginsdir. If that is not acceptable then you must modify INetC yourself...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 15th September 2018, 17:53   #32
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
Quote:
Originally Posted by Anders View Post
That is how ANSI works.

To support all languages on all computers you must use Unicode. I don't think there are any download plug-ins that will give you raw bytes or hex bytes on the stack you are stuck with downloading to a file to $pluginsdir. If that is not acceptable then you must modify INetC yourself...
Yes this not work with ansi!

but when i use the
HTML Code:
 unicode true
in .nsi file,then use from:
HTML Code:
MessageBox MB_OK|MB_RIGHT|MB_RTLREADING "سلام"
i see سلام in message


also when unicode is true
HTML Code:
 unicode true
when i use inetc plugin i see the messagebox sample this:



but download the text file and read the file and show in messagebox is show good

HTML Code:
inetc::get /NOCANCEL /SILENT "http://ariana-ac.ir/mjserver/white.txt" "$TEMP\Servers.txt" /end
FileOpen $4 "$TEMP\Servers.txt" r
FileRead $4 $1 
FileClose $4 

MessageBox MB_OK "$1"

My problem is here:
Why even though i use from
HTML Code:
 unicode true
and use inetc::get with /TOSTACK the words in variable $1 is Unreadable!??
The only solution to fix the problem is re-writing the new plugin?
Or edit the inetc plugin?
r2du-soft is offline   Reply With Quote
Old 15th September 2018, 17:55   #33
r2du-soft
Senior Member
 
r2du-soft's Avatar
 
Join Date: Nov 2013
Location: Iran
Posts: 269
Quote:
Originally Posted by need9989 View Post
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"
thanks need9989
but i do not want use from another exe file in installer.exe
r2du-soft is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump