Operating System - HP-UX
1833288 Members
3085 Online
110051 Solutions
New Discussion

Re: Double quotes not getting appended to the file

 
Kadavan
Occasional Advisor

Double quotes not getting appended to the file

Hi All

I am running a scripts to append the following line to a file

postschedulecmd "rm -f /opt/hd/sa/tmp/dsmsched.pru; touch /opt/hd/sa/tmp/dsmerror.log; chmod 666 /opt/hd/sa/tmp/dsmerror.log"

but while runnig the following script

ssh -n ${HOST} echo 'postschedulecmd \ "rm -f /opt/hd/sa/tmp/dsmsched.pru; touch /opt/hd/sa/tmp/dsmerror.log; chmod 666 /opt/hd/sa/tmp/dsmerror.log" >> /tmp/shaik'

the double quates are not getting updated in the file

Can you please help me in this

Regards
-Binu
3 REPLIES 3
klb
Valued Contributor

Re: Double quotes not getting appended to the file


Inside your echo ' ... ', the double quotes are being interpreted by the local shell ( I think ) or the remote shell.

To prevent that, escape them with a backslash as so...

echo 'posetschedulecmd \"rm -f ... \" >> /tmp/shaik'

So, if you want a double quote to be echoed, place a single backslash in front of it.

-klb
Wilfred Chau_1
Respected Contributor

Re: Double quotes not getting appended to the file

look like you have an extra space after the first back slash, and missing the back slash for the second quote.


now try again.
ssh -n ${HOST} echo 'postschedulecmd \"rm -f /opt/hd/sa/tmp/dsmsched.pru; touch /opt/hd/sa/tmp/dsmerror.log; chmod 666 /opt/hd/sa/tmp/dsmerror.log\" >> /tmp/shaik'
klb
Valued Contributor

Re: Double quotes not getting appended to the file


I figured the first \ was to continue on a new line, not intended as an escape.