quote escaping over ssh

Lonni J Friedman netllama at gmail.com
Thu Mar 20 10:28:20 PDT 2014


On Wed, Mar 19, 2014 at 8:01 PM, Sean Keating <sean at csupport.com> wrote:
> Wouldn't the correct way to escape the quotes be:
>
> ssh root at myhost.com 'grep \'\"priority\":\"err\"\' /var/log/local7.log'

Unfortunately, that doesnt 'work either, something isn't getting
escaped and the command never runs.

>
> The way you have it you are only escaping the second \.
>
> Also, someone suggested that you place the command on the remote
> machine, but you said it would be to difficult to maintain. Have thought
> about writing a script on your machine that copies the current script to
> your list of a thousand servers, runs the script, and then deletes the
> remote script?

i guess, but that's going to effectively double the time needed to run
through the process.

>
> Just a thought.
>
> Sean
>
>
>
>
> On Wed, 2014-03-19 at 15:26 -0700, Lonni J Friedman wrote:
>> Hi folks,
>> I've got a bizarro problem that is driving me mad.  I need to run a
>> command that has both single & double quotes, over ssh.  This is the
>> command which runs just fine if I'm already using an interactive shell
>> on a system:
>> grep '"priority":"err"' /var/log/local7.log
>>
>> Yes, I'm dealing with some crazy json formatted logs, which I have no
>> control over.
>>
>> However, what I want to do is run that command from a non-interactive
>> session over ssh.  I've tried different ways of escaping the quotes,
>> and nothing works.  This command isn't escaped properly and the entire
>> ssh command fails to run:
>> ssh root at myhost.com  'grep \'"priority":"err"\' /var/log/local7.log
>>
>> This seems to work, but the ssh command just hangs forever (normally
>> takes 1-3s to return):
>> ssh root at myhost.com  'grep \\'"priority":"err"\\' /var/log/local7.log'
>>
>> Surely I'm missing something simple?
>>
>> thanks
>>
>>
>
> --
> Sean Keating
> Computer Support, Inc
> Office: 401-885-2297
> Cell:   401-225-3545
> <sean at csupport.com>
>
> _______________________________________________
> Linux-users mailing list
> Linux-users at linux-sxs.org
> http://mailman.celestial.com/mailman/listinfo/linux-users



-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
L. Friedman                                    netllama at gmail.com
LlamaLand                       http://netllama.linux-sxs.org


More information about the Linux-users mailing list