Jason
Jason

Reputation: 75

Getting "Unknown command" error in WinSCP

I'm trying to automate sending a .xlsx file via SFTP using Task Scheduler and WinSCP. I can get WinSCP to launch and successfully authenticate, however it soon after returns the following and closes the connection

< 2023-04-03 19:44:36.835 Script: Active session: [1] [redacted]
> 2023-04-03 19:44:36.835 Script: directory of /
< 2023-04-03 19:44:36.835 Script: Unknown command 'directory'.
. 2023-04-03 19:44:36.836 Script: Failed
. 2023-04-03 19:44:36.837 Script: Exit code: 1
. 2023-04-03 19:44:36.837 Closing connection.

I haven't been able to figure out how to resolve the unknown command 'directory'.

Task Scheduler Arguments:

/script=C:[redacted]Script.txt /log=C:[redacted]Log.txt

Script file:

# Connect to SFTP server using username and password supplied
open sftp://username:password@[redacted]
# put the TB file(s) stored at the specified path (local directory) to the root
directory of /
# -nopreservetime = swallow a WinSCP error about logging a timestamp on the file
# -resumesupport=off = disable filepart extension to ensure WinSCP transfers the file
without disassembling
# -delete = clears the local directory after the file has been sent, since the future
TB will supersede it
put C:[redacted]\*.xlsx / -nopreservetime -resumesupport=off

Upvotes: 1

Views: 527

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202494

It looks like some of your comment lines got wrapped somewhere on the way, And as the wrapped parts do not start with #, WinSCP tries to interpret them as commands and fail.

It should be:

# put the TB file(s) stored at the specified path (local directory) to the root directory of /
# -nopreservetime = swallow a WinSCP error about logging a timestamp on the file
# -resumesupport=off = disable filepart extension to ensure WinSCP transfers the file without disassembling
# -delete = clears the local directory after the file has been sent, since the future TB will supersede it

Upvotes: 1

Related Questions