Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I must connect to server every day by ssh, and I made a script to display logs.

This is my code:

#!/bin/bash

A=`date +%Y`
M=`date +%m`
D=`date +%d`

gnome-terminal --geometry=82x11 \
--tab --title "NAMEServer" -e "sshpass -p P4ssw0rd ssh [email protected] 'tail -f /opt/logs/example.$A-$M-$D.log'" \
--tab --title "NAMEServer" -e "sshpass -p P4ssw0rd ssh [email protected] 'tail -f /opt/logs/example.$A-$M-$D.log'"

But if I try filter a words with grep, not working. Example:

-e "sshpass -p P4ssw0rd ssh [email protected] 'tail -f /opt/logs/example.$A-$M-$D.log | grep 'not fetch''" \

or

-e "sshpass -p P4ssw0rd ssh [email protected] 'cat /opt/logs/exaple.log | grep 'any problem''" \

I think the problem is the quotation marks, but, which use?, I tried with ´´ ' ' " ".

share|improve this question

1 Answer 1

You are correct, it is your quotation marks. You are nesting single quotes without escaping. Try this:

-e "sshpass -p P4ssw0rd ssh [email protected] 'cat /opt/logs/exaple.log | grep \'any problem\''" \
share|improve this answer
    
thanks @forquare, but I tried it, or assign a variable and not working. –  ymk369 Aug 28 at 1:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.