quote escaping over ssh
Lonni J Friedman
netllama at gmail.com
Wed Mar 19 16:28:29 PDT 2014
I wish it was that simple to work around. But the command will evolve
over time, and I need to run this command on several thousand systems,
and having to maintain a shell script on all of them would be rather
painful.
I tried your suggestion of doubling the single quotes:
ssh root at myhost.com 'grep ''"priority":"err"'' /var/log/local7.log'
the command seems to work (it returns after a second), but never
returns any output. Running it locally on the system returns output,
so the grep command isn't working.
On Wed, Mar 19, 2014 at 4:24 PM, Michael Hipp <michael at redmule.com> wrote:
> 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
>>
>>
>
> _______________________________________________
> 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