Archive for the ‘FTP’ Category

This is a quick example of how to automate a FTP task with a batch file. WinSCP allows you to utilize a script file with your connection details and commands, which makes things very easy.

Save the following details into “myscript.txt”:

# Answer all prompts negatively so the script
#does not stall on error
option batch on
# Disable overwrite confirmations
option confirm off
# Connect using a password
open ftp://myftpusername:mypassword@127.0.0.1:21
# Upload files
put C:\mydirectory

Make sure to update these values appropriately:
myftpusername = FTP username
mypassword = FTP user’s password
127.0.0.1 = IP or hostname of machine you are connecting to
C:\mydirectory = directory you wish to copy to the home directory of your FTP user

Then the following can be placed in a .bat file to execute the upload above:

C:\Program Files\WinSCP\winscp.exe /console /script=myscript.txt

Note you may need to update the path to the WinSCP executable or the myscript.txt file depending on your installation.

In order for FileZilla Server’s FTP users to be able to access files on a NAS device, a few changes are needed.

Update user that FileZilla Server runs as
First the user account that the FileZilla Server service runs as needs to be updated. By default it uses the local system account which does not exist on the NAS. Unless the NAS and server are part of an Active Directory setup, the only user that exists on the NAS is “administrator”. Create this same Administrator user in Windows on your server then follow these steps:

1. Open services (Start -> Run -> Services.msc)
2. Right click the “FileZilla Server FTP server” service and choose Properties
3. On the “Log On” tab check “This account” -> Browse -> Advanced -> Find Now -> Select “Administrator” -> OK -> OK
4. Enter the password for this user -> Confirm it -> Click OK

Setup FTP user and manually edit home directory
Next create a FTP user in FileZilla with access to a directory local to that server. Do not try to point it to a mapped drive for the NAS. Then manually set the home directory to the UNC path:

1. Stop the FileZilla Server service
2. Open “FileZilla Server.xml” in a text editor like Notepad
-Usually located here:
C:\Program Files\FileZilla Server
3. Scroll down to the username or search for it
4. Locate the “Permission Dir” field
5. Replace the local folder path with the appropriate UNC path. For instance:
\\123.456.78.90\Path\To\Files
6. Start the FileZilla Server service

Note: You will also need a FTP client which supports UNC paths. Most clients do at this point but the more basic ones won’t. FileZilla Client version 3 or newer should work fine.