Topic "Script: Unknown command '2048'."

Author Message
akksam
[View user's profile]

Joined: 2016-05-09
Posts: 3
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
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
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
[View user's profile]

Joined: 2016-05-09
Posts: 3
Thanks ! the requirement is to use PowerShell code and not any dll's. would you please hint anything to resolve this from powershell?
akksam
[View user's profile]

Joined: 2016-05-09
Posts: 3
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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
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.
Advertisements

You can post new topics in this forum






Search Site

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