quote escaping over ssh

Lonni J Friedman netllama at gmail.com
Wed Mar 19 15:26:42 PDT 2014


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


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


More information about the Linux-users mailing list