Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to call an ssh command from a Windows command prompt that will execute a command on a remote Linux machine. The command accepts two string parameters, one of which can potentially be multi-lined. Basically, my call looks something like this:

ssh user@server command parameter1 parameter2

This fails miserably when there are spaces in the parameters. I've tried to escape the parameters with ', but those are stripped by the Windows box, and the Linux then mangles the parameters. I've tried also ", and those ok by the Windows box, but the Linux just ignores them. The version where I use both, like this

ssh user@server command "'para meter 1'" "'para meter 2'"

kinda-sorta works, but now I have the problem of in-line quotes. Is there any standard way that I would make both Linux and Windows understand both spaces, single and double quotes?

share|improve this question

1 Answer 1

I would imagine that the following would work quite well:

ssh user@server "command \"parameter 1\" \"parameter 2\""

Of course, then you still have the problem of needing to double-escape the double quotes inside your parameters.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.