Sunday, October 18, 2015

How to pass a windows path with spaces to cygwin bash


I am connecting to a windows server (2012R2 64 bit) running cygwin (latest version that i downloaded from cygwin.com yesterday) using putty.


I am trying to run cmd.exe and pass the cmd.exe a command that is located in "Program Files (x86)".


this is what i am trying run:
cmd.exe /C "c:\program files (x86)\ibm\rationalsdlc\clearcase\bin\cleartool.exe"


and i get: 'c:\program' is not recognized as an internal or external command,
operable program or batch file.


i tried it with "\" and with "\" and got the same message.


when i doubled the brackets (") like this:
cmd.exe /C ""c:\program files (x86)\ibm\rationalsdlc\clearcase\bin\cleartool.exe""


i got -bash: syntax error near unexpected token `('


When i tried to pass a different string with no spaces in the path
for example: cmd.exe /C "ccperl C:\utils\find-locked-vobs.pl" it works OK and the perl script runs OK.


How do i pass a command when the pass contains spaces?


Thank you
David


Answer



Assuming you are running bash and you want to pass the full windows path to cmd,
you should use single apostrophe and not double


cmd /c 'C:\Program Files (x86)\Adobe\Reader 10.0\Reader\acrord32.exe'


works fine for me.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...