Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 1st August 2012, 08:45   #1
mrjohn
Junior Member
 
Join Date: Feb 2009
Posts: 40
Select and download files from ftp folder

Hi ! I need to create one installer that connects to a ftp folder,gets a list of files there and then gives the option to download some of them.Is this possible with NSIS ?
Thanks !
mrjohn is offline   Reply With Quote
Old 1st August 2012, 11:23   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
Either write a plug-in to do it, call an existing DLL using the System plug-in or execute an existing command line executable (search Google for a DLL/EXE to use).

Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 1st August 2012, 12:22   #3
mrjohn
Junior Member
 
Join Date: Feb 2009
Posts: 40
Thanks for the answer!
mrjohn is offline   Reply With Quote
Old 1st August 2012, 17:08   #4
mrjohn
Junior Member
 
Join Date: Feb 2009
Posts: 40
For me it is hard to do that with NSIS,I don't know how to write plugin,I think i'll write a .NET app that will do the work,and I'll use it as an installer,the single problem is : there must be FRAMEWORK installed on the computer
mrjohn is offline   Reply With Quote
Old 1st August 2012, 19:13   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
Did you search for a DLL or command line FTP client for Windows? You can use either through NSIS.

Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 2nd August 2012, 06:12   #6
T.Slappy
Senior Member
 
T.Slappy's Avatar
 
Join Date: Jan 2006
Location: Slovakia
Posts: 361
Send a message via ICQ to T.Slappy
In present times Framework is installed on most machines.
If not then it is very easy to detect it, download and install using NSIS

Create cool looking Graphical Installers in NSIS: www.graphical-installer.com -see below
I offer NSIS scripting, C/C++/C#/Delphi programming: www.unsigned-softworks.sk
Develop NSIS projects directly in Visual Studio 2005-2012: www.unsigned-softworks.sk/visual-installer/
T.Slappy is offline   Reply With Quote
Old 2nd August 2012, 06:42   #7
mrjohn
Junior Member
 
Join Date: Feb 2009
Posts: 40
Hi ! I've searched for command line but I found lot of things:commercial,mounting ftp to drive,etc,not something clearly,I'll do as T.Slappy suggested,thanks !
mrjohn is offline   Reply With Quote
Old 2nd August 2012, 07:03   #8
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,839
Err... Making your installer download and install .NET is not a better solution. For one thing, it requires a reboot. Second, it makes your installer much much more complex. Third, lots of people don't want to install .NET. Fourth, installation will take much longer.

There are plenty of free commandline-based FTP tools out there. http://www.ncftp.com/ncftp/ is my third google hit.
MSG is offline   Reply With Quote
Old 2nd August 2012, 08:13   #9
mrjohn
Junior Member
 
Join Date: Feb 2009
Posts: 40
Thanks all of you'I don't want to annoy you,but for me the shortest road is the road I know,I tried ncftp but I couldn,'t connect to my ftp account with this tool,also I don't know how to add files into NSIS installer,it is too hard,i'll use .NET solution,thanks

Quote:
Originally Posted by MSG View Post
Err... Making your installer download and install .NET is not a better solution. For one thing, it requires a reboot. Second, it makes your installer much much more complex. Third, lots of people don't want to install .NET. Fourth, installation will take much longer.

There are plenty of free commandline-based FTP tools out there. http://www.ncftp.com/ncftp/ is my third google hit.
mrjohn is offline   Reply With Quote
Old 2nd August 2012, 09:48   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
Actually a fresh .NET installation does not require a reboot. Regarding FTP, one tool that comes to mind is wget. It is free and there is a Windows port (Google it) and it supports FTP file/folder listings IIRC.

Edit: cURL is another one.

Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 2nd August 2012, 11:30   #11
mrjohn
Junior Member
 
Join Date: Feb 2009
Posts: 40
Quote:
Originally Posted by Afrow UK View Post
Regarding FTP, one tool that comes to mind is wget
Indeed wget works

PHP Code:
wget   --ftp-user=myuser --ftp-password=mypassw  ftp://mywebserver.com/update/ 
it lists files from a folder creating a file like this :

PHP Code:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<
html>
<
head>
<
title>Index of /update on mywebserver.com:21</title>
</
head>
<
body>
<
h1>Index of /update on mywebserver.com:21</h1>
<
hr>
<
pre>
  
2012 Jul 30 15:28  File        <a href="ftp://mywebserver.com:21/update/upd_C_1_0_5_97.exe">upd_C_1_0_5_97.exe</a>  (1198819 bytes)
  
2012 Aug 02 05:49  File        <a href="ftp://mywebserver.com:21/update/upd_G_1_0_9_39.exe">upd_G_1_0_9_39.exe</a>  (1343629 bytes)
  
2012 Mar 13 06:31  File        <a href="ftp://mywebserver.com:21/update/upd_H_1_0_0_18.exe">upd_H_1_0_0_18.exe</a>  (488752 bytes)
  
2012 Feb 13 03:09  File        <a href="ftp://mywebserver.com:21/update/upd_M_1_0_20_15.exe">upd_M_1_0_20_15.exe</a>  (564734 bytes)
  
2012 Jul 31 02:13  File        <a href="ftp://mywebserver.com:21/update/upd_S_1_0_2_57.exe">upd_S_1_0_2_57.exe</a>  (1249680 bytes)
</
pre>
</
body>
</
html
now how to get files into NSIS to let user select what files wants to download ?
Thanks !
mrjohn is offline   Reply With Quote
Old 2nd August 2012, 15:30   #12
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,839
You'll probably have to download the file list and direct output to a file:
SetOutPath $PLUGINSDIR
File ftpclient.exe
nsExec::Exec `"$PLUGINSDIR\ftpclient.exe" -param1 -param2 -etc > "$PLUGINSDIR\filelist.txt"`

And then parse that txt file using the macros listed in Appendix E of the manual: http://nsis.sourceforge.net/Docs/AppendixE.html

You could output what you find to a listbox with checkboxes, or some similar control. Google finds http://forums.winamp.com/showthread.php?t=318260 , which links to http://nsis.sourceforge.net/EmbeddedLists_plug-in .
You could of course also make a hundred hidden sections, then unhide & rename the sections after you get the filelist. One section for each file. Then you could just use the components page, instead of bothering with a checkbox'ed listbox control.
MSG is offline   Reply With Quote
Old 3rd August 2012, 10:48   #13
mrjohn
Junior Member
 
Join Date: Feb 2009
Posts: 40
Thanks MSG !!!
I've done,I've created sections (I have max 7 ) default hidden (name ="") and I show them after getting the file list,I used SectionSetText.... all works, but instead using wget to download the files that shows a command window I want to use something with a real progressbar so I tried Inetc plugin, but I can't download the file with it,also with wget I can,this is the command I use :


PHP Code:
 inetc::get /caption "download" /popup "ftp://mywebserver*******" "ftp://myuser@mywebserver.info:mypassw@mywebserver*******update/upd_H_1_0_0_18.exe" "$EXEDIR\setup.exe"

    
Pop $# return value = exit code, "OK" if OK
    
MessageBox MB_OK "Download Status: $0" 
I got error : URL Parts Error

Thanks !
mrjohn is offline   Reply With Quote
Old 3rd August 2012, 12:07   #14
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
Put /end on the end of your inetc line.

Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 3rd August 2012, 12:22   #15
mrjohn
Junior Member
 
Join Date: Feb 2009
Posts: 40
Done, but the same error

thanks
Quote:
Originally Posted by Afrow UK View Post
Put /end on the end of your inetc line.

Stu
mrjohn is offline   Reply With Quote
Old 3rd August 2012, 13:05   #16
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
Does it work without the /caption and /popup switches? If not then I would suspect your URL format is wrong as then I'd assume that error means InternetCrackUrl API failed.

Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 3rd August 2012, 14:29   #17
mrjohn
Junior Member
 
Join Date: Feb 2009
Posts: 40
Hi !
I tried something like this, rename user to
myuser
not
myuser@mywebserver.info

user is defined in cpanel as myuser@mywebserver.info,tested also with browser,simple name myuser doesnt work


So using simple myuser I can see the progressbar and then the message : Download Status:530:Login autenthication failed

PHP Code:
  inetc::get   "ftp://myuser:mypass@mywebserver*******public_html/pft/_public_/update/upd_H_1_0_0_18.exe" "$EXEDIR\setup.exe" 
puting back the user to myuser@mywebserver.info got error : URL Parts Error

Thanks!





Quote:
Originally Posted by Afrow UK View Post
Does it work without the /caption and /popup switches? If not then I would suspect your URL format is wrong as then I'd assume that error means InternetCrackUrl API failed.

Stu
mrjohn is offline   Reply With Quote
Old 3rd August 2012, 15:23   #18
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
This worked for me:
code:
inetc::get "ftp://myuser:mypass@mywebserver.com/public_html/pft/_public_/update/upd_H_1_0_0_18.exe" "$EXEDIR\setup.exe" /end
You sure you put /end on correctly (as shown)?

Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 3rd August 2012, 19:16   #19
mrjohn
Junior Member
 
Join Date: Feb 2009
Posts: 40
not working,I think there must be a bug when user is defined as
myuser@mywebserver.info
not
myuser

Thanks



Quote:
Originally Posted by Afrow UK View Post
This worked for me:
code:
inetc::get "ftp://myuser:mypass@mywebserver.com/public_html/pft/_public_/update/upd_H_1_0_0_18.exe" "$EXEDIR\setup.exe" /end
You sure you put /end on correctly (as shown)?

Stu
mrjohn is offline   Reply With Quote
Old 3rd August 2012, 22:58   #20
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
You can't have an @ in the username (or password). The FTP URI specification does not allow it.

It has to be:
ftp://<user>:<pass>@<host>/<path>

Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 4th August 2012, 05:51   #21
mrjohn
Junior Member
 
Join Date: Feb 2009
Posts: 40
In wget I use it like this and it works :

PHP Code:
 nsExec::Exec '"wget.exe"  --ftp-user=myuser@mywebserver.info --ftp-password=mypassw ftp://mywebserver*******update/ ' 
using in wget username myuser instead of myuser@mywebserver.info it doesn't work,so I think there is a bug in this plugin,also it is working with total commander,chrome,firefox,etc

Thanks!


Quote:
Originally Posted by Afrow UK View Post
You can't have an @ in the username (or password). The FTP URI specification does not allow it.

It has to be:
ftp://<user>:<pass>@<host>/<path>

Stu
mrjohn is offline   Reply With Quote
Old 4th August 2012, 09:59   #22
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
As I said it's the FTP URI specification that does not allow the @ in the username when the username is in the URI. The @ is used as the delimiter between the username and password therefore it cannot allow more than one. This is not a fault of the plug-in. Try it in IE (or any other browser) for example. The reason it works with wget is because you're not specifying the username in the FTP URI. If you are stuck with that username then you will have to use wget instead of inetc.

Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 4th August 2012, 16:13   #23
mrjohn
Junior Member
 
Join Date: Feb 2009
Posts: 40
Thanks Afrow, I'll use wget.
mrjohn is offline   Reply With Quote
Reply
Go Back   Winamp 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