Topic "Encoding problem when executing a WinSCP script generated using MS SQL Server"

Author Message
konraddo
[View user's profile]

Joined: 2017-05-31
Posts: 2
Location: Poland
Hello, i have a problem:
I'm using WinSCP to upload files to a server using script, since I store files list in MS SQL database, I tried to create a script for WinSCP from SQL Stored procedure by concatenating strings and saving results to file using SQL CLR assembly, but it seems there's a problem with newline characters - in SQL i use CHAR(13) + CHAR(10) and when i'm trying to connect to server using WinSCP i've got error:
"Ambiguous command 'o'. Possible matches are: open, option".
But when I edit this script manually in notepad.exe, even if i don't edit a single character and save it, it works. How should i properly handle newline characters for WinSCP?
Or is there a way to change accepted encoding of scripts in WinSCP? I googled about encoding settings in WinSCP but if i understand correctly, you can change encoding of files transferred using WinSCP, not encoding of the WinSCP script.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
Show us some code.
konraddo
[View user's profile]

Joined: 2017-05-31
Posts: 2
Location: Poland
Okay, so i post attachment with script that i'm executing (i'm not pasting it on pastebin.com or somewhere else because it could possibly affect encoding?).

This is how i execute this script:

winscp.com /script=G:\Synchronize_photos\20170601_121717.txt
this gives me this error:
Ambiguous command 'o'. Possible matches are: open, option.

When i try to execute another version of this script (edited and saved in Notepad without doing any modifications), WinSCP successfully executes this script:
winscp.com /script=G:\Synchronize_photos\20170601_121717_savedInNotepad.txt
Searching for host...
Network error: Connection to "examplewebsite.com" timed out.
which is of course fine because i changed actual URL with this fake example.
20170601_121717.zip (894 Bytes) [Download]

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
The 20170601_121717.txt is saved in UTF-16 encoding without a BOM.

While the 20170601_121717_savedInNotepad.txt has the BOM. Note that it's two bytes larger (that's the BOM).

WinSCP needs either UTF-8-encoded script file; or a BOM to identify, that the file uses a different UTF encoding (such as UTF-16)
See https://winscp.net/eng/docs/scripting#using_scripting
Advertisements

You can post new topics in this forum






Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License