Sailwave is a windows based application that manages scoring and results for sail races and series See http://www.sailwave.com/
Sailwave comes with many different ways to ‘publish’ results, including FTP’ing the html results files to a server.
Whilst there are many ways to achieve the desired results, the situation arose that my server no longer supported FTP ( like many now as it is not a secure protocol) and I still wanted the results files on my server as I manipulate them with some PHP to tightly integrate them to the club website’s code.
The solution is to use SCP in my case ( or SFTP could do ) and for windows that means using WinSCP. My solution uses certificated access, although password access can be achieved if your server permits this.
The solution captitalises on the fact that Sailave has a ‘publish’ option to a windows application.
Four main steps
- Download and install WinSCP
- Generate Secure Keys, using PuttyGen
- Configure two simple scripts
- Add the script to the ‘publish to application’ in Sailwave
Download and install WinSCP
Like many free software finding the download is a chore as there are many adverts – but this link should do it https://winscp.net/download/WinSCP-5.9.1-Setup.exe and the download will start automatically.
Once download click & install using the defaults in the normal way.
To avoid having to include the full path of WinSCP later, it makes things easier (and this post is based on) if you add The WinSCP install directory to your PATH variables
On Windows 10, right click the windows item, select ‘system’ then ‘advanced systems settings’ then the ‘environment variables’ button.
If you have a variable called PATH, select and edit, or create a new variable if you don’t. Then add a new item which will be where you installed WinSCP – C:\Program Files (x86)\WinSCP – is the default on Windows 10
Generate Secure Keys using PuttyGen
PuttyGen should have been installed with WinSCP.
Instructions are here https://winscp.net/eng/docs/ui_puttygen#obtaining_and_starting_puttygen
If your server is Linux (most are) you will then need to paste your public key into your server users ~/.ssh/authorized_keys files (see the section on the above page Public Key for Pasting into authorized_keys File )
As mentioned, using keys is optional, and passwords can be used if permitted on your server. If you use passwords though the scripts below will need to be modified.
At this stage it is a good idea to create your local working directory. For the sake of this it will be c:\Sailwave\WebPublish
Save your private key file e.g. key.ppk into c:\Sailwave\WebPublish and I’ll assume you use a key passphrase when you created it e.g. mysecret
At this stage, you might like to just test that you can log in with the desktop WinSCP – see https://winscp.net/eng/docs/ui_login
Configure two simple scripts
The first script is the command line script to operate WinSCP. Using a text editor ( NotePad++ is a lot better than the standard Notepad on Windows – see https://notepad-plus-plus.org/download/v6.9.2.html and more than up to the task – or if you want a really good code editor use Atom – see https://atom.io/ but goes way beyond what is required here ) create a file in your c:\Sailwave\WebPublish directory called put.script with the following content, replacing the user, domain and the full path but leave the %2% at the end
open scp://firstname.lastname@example.org/ -passphrase=mysecret -privatekey=key.ppk put %1% /replace_with_your_own_full_path/home/user/public_html/uploads/sailwave/%2% exit
You should be able to test this simply enough, create a test file e.g.
in your directory and run
WinSCP.com /script=put.script /parameter my_remote_file.txt my_local_file.txt
If it runs it may ask about server fingerprints, say ‘yes’ and hopefully your local file gets uploaded as your remote file on the – if it works then delete your test files.
Create a new file called put.cmd with the following content
cd c:\Sailwave\WebPublish set arg1=%1 set arg2=%2 WinSCP.com /script=put.script /parameter %arg2% %arg1%
So now in c:\Sailwave\WebPublish you shoudl have 3 files
Now the easy bit
Add the script to the ‘publish to application’ in Sailwave
Within SailWave, go to the publish results pop up (ctril-P) and select next, set destination to ‘An installed application’
and input in the Application (replacing your destination path) something like
The /mypath/myresults.html is where the file ends up on the server, so in this example
as it joins up with the path specified in put.script above.
Then publish, and check it worked.
A little black window should pop up and disappear on completion, if you are having trouble testing, simply remove the ‘exit’ line from the put.script file, the window will stay open (until you type exit) giving you a chance to read any error messages.
I recently assisted a club who’s website is on WP Engine and had to make some adjustments as scp wasn’t available only sftp, they use a different port, and certificated access is not required. The put.script ended up similar to as follows, obviously change the user/ password ( and if required port number, which for WP Engine is 2222 )
open sftp://myuser:email@example.com:2222/ put %1% /replace_with_your_own_full_path/%2% exit