Too many parameters for command 'open'

Advertisement

d.gerrardboards
Joined:
Posts:
2
Location:
UK

Too many parameters for command 'open'

Good Afternoon,

Can anyone offer advice on the below? Spent days and can't figure it out.

Everything seemed to work before I specified the hostkey, now I can succesfully run the connection part of the script, but not rm onwards.

winscp.com /command "open sftp://bla@bla.com/ -hostkey="C:\bla\sqlbackup\HOST.ppk" -privatekey="C:\bla\sqlbackup\SFTP.ppk" "rm TEST.TXT" "put C:\bla\sqlbackup\TEST.TXT" exit

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
29,502
Location:
Prague, Czechia

Re: Too many parameters for command 'open'

If you need to use double quotes around switch value, you have to double them. See
https://winscp.net/eng/docs/commandline#syntax

Also, the value of -hostkey is a fingerprint not a path to a file.
https://winscp.net/eng/docs/scriptcommand_open#hostkey

winscp.com /command "open sftp://bla@bla.com/ -hostkey=""ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx..."" -privatekey=""C:\bla\sqlbackup\SFTP.ppk""" "rm TEST.TXT" "put C:\bla\sqlbackup\TEST.TXT" exit

The easiest is to configure the session in WinSCP GUI and have it generate the command-line for you:
https://winscp.net/eng/docs/ui_generateurl#script

Reply with quote

d.gerrardboards
Joined:
Posts:
2
Location:
UK

Re: Too many parameters for command 'open'

martin wrote:

If you need to use double quotes around switch value, you have to double them. See
https://winscp.net/eng/docs/commandline#syntax

Also, the value of -hostkey is a fingerprint not a path to a file.
https://winscp.net/eng/docs/scriptcommand_open#hostkey

winscp.com /command "open sftp://bla@bla.com/ -hostkey=""ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx..."" -privatekey=""C:\bla\sqlbackup\SFTP.ppk""" "rm TEST.TXT" "put C:\bla\sqlbackup\TEST.TXT" exit

The easiest is to configure the session in WinSCP GUI and have it generate the command-line for you:
https://winscp.net/eng/docs/ui_generateurl#script

That's done it! Damn, thought I could put the hostkey in a file.
Thanks for your help

Reply with quote

Advertisement

You can post new topics in this forum