Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

akksam wrote:

Found the root cause of the issue but not sure what would be the fix. Kindly advice

Log when I manually executed the command from DOS this works fine
...

That's what I've meant.

But again, I'm not a PowerShell expert. Ask in some PowerShell community, or maybe at stackoverflow.com or superuser.com.
akksam

Found the root cause of the issue but not sure what would be the fix. Kindly advice

Log when I manually executed the command from DOS this works fine

. 2016-05-10 01:01:23.905 Switch: /command
. 2016-05-10 01:01:23.905 Parameter: open sftp://name:password@domain.com -hostkey="ssh-rsa 2048 **:**:**:**:**:**:**:**:**:**:**:**:**:**:**:**"
. 2016-05-10 01:01:23.905 Switch: /log=G:\winscp577\winscp.log
. 2016-05-10 01:01:23.905 Switch: /loglevel=1


Log when I executed the command from PowerShell this is not working
Powershell code: G:\winscp577\winscp /command "open sftp://name:password@domain.com -hostkey=""ssh-rsa **** **:**:**:**:**:**:**:**:**:**:**:**:**:**:**:**""" /log="G:\winscp577\winscp.log" /loglevel=0

Not sure why the command is separated in to 3 lines and there is no double quotes before ssh-rsa

. 2016-05-10 01:13:33.609 Switch: /command
. 2016-05-10 01:13:33.609 Parameter: open sftp://name:password@domain.com -hostkey=ssh-rsa
. 2016-05-10 01:13:33.609 Parameter: 2048
. 2016-05-10 01:13:33.609 Parameter: **:**:**:**:**:**:**:**:**:**:**:**:**:**:**:**"

. 2016-05-10 01:13:33.609 Switch: /log=G:\winscp577\winscp.log
. 2016-05-10 01:13:33.609 Switch: /loglevel=1
akksam

Thanks ! the requirement is to use PowerShell code and not any dll's. would you please hint anything to resolve this from powershell?
martin

Re: Script: Unknown command '2048'.

It's looks like a PowerShell issue, not WinSCP one.

The PowerShell messes with the quotes on WinSCP command-line somehow.

But I'm no PowerShell expert to tell you how to escape them.

Why don't you use WinSCP .NET assembly?
https://winscp.net/eng/docs/library_powershell
akksam

Script: Unknown command '2048'.

Hi, Could anyone please help in come out of this challenge? Your earliest advise will be greatly appreciated.

When I trigger the following command from PowerShell code getting "Script: Unknown command '2048'. " but if I execute the same from DOS it works fine.
I am not able to understand why this command is not working in PowerShell.

The execution command coded in powershell is that G:\winscp577\winscp /command "open sftp://name:password@domain.com -hostkey=""ssh-rsa **** **:**:**:**:**:**:**:**:**:**:**:**:**:**:**:**""" "ls" /log="G:\winscp577\winscp.log" /loglevel=0

winscp.log says;

< 2016-05-01 11:23:18.795 Script: Active session: [1] name@domain.com
> 2016-05-01 11:23:18.795 Script: 2048
< 2016-05-01 11:23:18.795 Script: Unknown command '2048'.
. 2016-05-01 11:23:18.795 Script: Failed
. 2016-05-01 11:23:18.795 Script: Exit code: 1
. 2016-05-01 11:23:18.795 Closing connection.
. 2016-05-01 11:23:18.795 Sending special code: 12
. 2016-05-01 11:23:18.795 Sent EOF message