Search code examples
bashquoting

execute remote command on remote windows via linux while escaping quotes


On windows following command works fine.

typeperf -sc 1 -si 1 "\\MYSERVER\Forefront TMG Web Proxy\Cache Hit Ratio (%)"

"01/04/2017 13:28:57.721","14.000000"

I want to execute above query from my linux box. This is what I am using

root@linux:/temp# winexe -U domain/admin%password //MYSERVER "typeperf -sc 1 -si 1 "\\MYSERVER\Forefront TMG Web Proxy\Cache Hit Ratio (%)"

-bash: syntax error near unexpected token `('

How can I query above command from my Linux to get required result which is "14.000000"


Solution

  • As Cyrus indicated in comments, you have a un-balanced double-quote, try this below.

    winexe -U domain/admin%"password" //MYSERVER 'typeperf -sc 1 -si 1 "\\MYSERVER\Forefront TMG Web Proxy\Cache Hit Ratio (%)"'
    

    I guess it is acceptable to wrap the outer commands within single-quotes and inner command within double-quotes.