I want to use ssh to add a register key on remote ssh server. Since there are space characters in my register key string, it always failed. If there is no space characters in the string, it worked fine. The following is what I have tried. It seems that "ssh" command doesn't care about double quotes, it just ignores them. Does anyone know how to make it work?
The ssh command does care about double quotes, if it sees them. But cmd.exe doesn't build the arguments right. It doesn't even allow you to escape anything (as you tried) since the backslash is used as path separator.
Thank you for reply! So I have to find an alternative to make it work.
---------- Post updated at 12:01 PM ---------- Previous update was at 09:43 AM ----------
I tried to add the register key on server locally. There is no problem when I ran "REG ADD..." directly under command line with space characters in the register key string.
C:\>REG ADD "HKLM\Software\My Co" /v Data /t REG_BINARY /d fe340ead
The operation completed successfully.
Or if I run ssh to login my ssh server ADM_B first and then run the command above, it still works fine.
C:\>ssh ADM_B
Last login: Wed Dec 2 15:36:28 2009 from adm_p
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.
C:\cygwin\home\AspectRoot>REG ADD "HKLM\Software\My Co" /v cat /t REG_SZ /d 100 /f
The operation completed successfully.
What is the difference between running "ssh" and "REG ADD" in two steps and running both in one command line on client?
In your two examples, this is what REG sees as it's arguments:
ADD
HKLM\Software\My Co
/v
Data
/t
REG_SZ
/d
100
/f
However, since to the Windows "shell" being very, very, very limited and not allowing nested quotes, this is what your ssh command looks like:
ADM_B
REG
ADD
HKLM\Software\My
Co
/v
cat
/t
REG_SZ
/d
100
/f
But since you've apparently got Cygwin installed anyways, use the Bash shell that's installed with it, since this shell knows about different types of quotes and how to nest them.
---------- Post updated at 11:25 AM ---------- Previous update was at 10:42 AM ----------
I tried to run the same command line under Bash shell. But it still failed and got the same result. It seems that double quotes are needed, but ssh still doesn't like space character.