Differences between version 42 and predecessor to the previous major change of BashNotes.
Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 42 | Last edited on Thursday, August 3, 2006 9:51:33 pm | by AristotlePagaltzis | Revert |
Older page: | version 41 | Last edited on Thursday, August 3, 2006 10:42:13 am | by IanMcDonald | Revert |
@@ -317,24 +317,38 @@
"\e[B": history-search-forward
"\e[A": history-search-backward
</verbatim>
-!! How do I feed "s
to the other end of an SSH session?
+!! How do I feed quote characters
to the other end of an [
SSH]
session?
-I have a bunch of remote machines with a config file that has some <tt>OPTIONS=something</tt>, and I want to set them all across-the-board to <tt>OPTIONS="foo"</tt>.
+I have a bunch of remote machines with a config file that has some <tt>OPTIONS=something</tt>, and I want to set them all across-the-board to <tt>OPTIONS="foo"</tt>. Locally, I would do it this way:
-Locally, I would use
<tt
>sed -i -e 's/OPTIONS=.*/OPTIONS="foo"/' file</tt
>.
This is hard to send over SSH however, as bash(1) locally likes to eat all your quotes, so they never reach the other end.
+<verbatim
>
+
sed -i -e 's/OPTIONS=.*/OPTIONS="foo"/' file
+
</verbatim
>
+
+
This is hard to send over [
SSH]
however, as bash(1) locally likes to eat all your quotes, so they never reach the other end.
PerryLorier's most bodacious answer:
<verbatim>
-ssh site sed -i -e \''s/OPTIONS=.*/OPTIONS="-x --round-robin --max-children 3
"/'\' /etc/default/spamassassin
+ssh site sed -i -e \''s/OPTIONS=.*/OPTIONS="foo
"/'\' file
</verbatim>
If anyone else has an answer, please add it, rather than replacing this one; I can at least understand what happens here. One set of brackets is eaten locally, and another set is sent to the other end, so the sed command ends up with 's when run on the remote host. —CraigBox
+
+Another option:
+
+<verbatim>
+ssh site <<'END_SCRIPT'
+sed -i -e 's/OPTIONS=.*/OPTIONS="foo"/' file
+END_SCRIPT
+</verbatim>
+
+—AristotlePagaltzis
!! See also
* CommonErrors, under "Your shell hangs"
* BashOneLiners
* SpacesInPathNames
* PortabilityNotes