Archive: Select and download files from ftp folder


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 !


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


Thanks for the answer!


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 :(


Did you search for a DLL or command line FTP client for Windows? You can use either through NSIS.

Stu


In present times Framework is installed on most machines.
If not then it is very easy to detect it, download and install using NSIS :)


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 !


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.


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

Originally posted by MSG
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.

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


Originally posted by Afrow UK
Regarding FTP, one tool that comes to mind is wget
Indeed wget works

wget  --ftp-user=myuser --ftp-password=mypassw  ftp://mywebserver.com/update/ 

it lists files from a folder creating a file like this :

<!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 !

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.


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 :


 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 $0 # return value = exit code, "OK" if OK
MessageBox MB_OK "Download Status: $0"
I got error : URL Parts Error

Thanks !

Put /end on the end of your inetc line.

Stu


Done, but the same error

thanks

Originally posted by Afrow UK
Put /end on the end of your inetc line.

Stu

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


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

  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!





Originally posted by Afrow UK
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

This worked for me:

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

not working,I think there must be a bug when user is defined as
myuser@mywebserver.info
not
myuser

Thanks



Originally posted by Afrow UK
This worked for me:
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

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


In wget I use it like this and it works :

 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!


Originally posted by Afrow UK
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

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


Thanks Afrow, I'll use wget.