I want to ssh to a node (which is passwordless) and append $spool_as_final_name true to a file /var/spool/torque/mom_priv/config. Note that is mandatory to put $ in front of the string.

So, I wrote

ssh node01 "echo \"\$spool_as_final_name true\" >> /var/spool/torque/mom_priv/config" 

However the file looks like


I intentionally wrote Dummy to show you that true is written in the second column.

How can I fix that?


Simply use,

ssh node1 'echo "\$spool_as_final_name true" >> /var/spool/torque/mom_priv/config'

Or you can use the cat command,

echo "\$spool_as_final_name true" | ssh node1 "cat >> /var/spool/torque/mom_priv/config"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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