LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problem echoing text to shell file with quotes in the middle of the echo command (https://www.linuxquestions.org/questions/linux-newbie-8/problem-echoing-text-to-shell-file-with-quotes-in-the-middle-of-the-echo-command-4175495091/)

AntBla 02-16-2014 02:45 AM

Problem echoing text to shell file with quotes in the middle of the echo command
 
Hi all.

I have a question that I think might be simple to answer, but I can't crack it after an hour or so of trying.
I am trying to create an installer.sh script that will create other shell scripts in the /usr/local/bin folder
The problem I have is that I want to use this line to echo the output to a file called test.sh

echo "ssh tunnel.somedomain.com.au "echo 2>&1" && echo host OK || sh /usr/local/bin/killtunnel.sh">>/usr/local/bin/test.sh

The line I want to appear in test.sh is
ssh tunnel.somedomain.com.au "echo 2>&1" && echo host OK || sh /usr/local/bin/killtunnel.sh

The problem I have is that there are quotes "" inside quotes which is not working.

Can anyone point me to the correct syntax? Or suggest a better way?

Thanks.

Ant.

pan64 02-16-2014 02:51 AM

have you tried ' or \" ?

ondoho 02-16-2014 06:56 AM

...meaning:
Code:

echo '"ssh tunnel.somedomain.com.au "echo 2>&1" && echo host OK || sh /usr/local/bin/killtunnel.sh"' >> /usr/local/bin/test.sh
that should do it.


All times are GMT -5. The time now is 04:42 AM.