quote escaping over ssh

Michael Hipp michael at redmule.com
Wed Mar 19 16:24:29 PDT 2014


I don't know the answer to the question. But what if you just put that 
command in a shell script on the far end and run the script?

Did you try doubling the single quotes ''? One of the shells is probably 
removing a set of quotes.

Michael

On 3/19/2014 5:26 PM, 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
>
>



More information about the Linux-users mailing list