{"id":1262,"date":"2014-04-29T14:54:01","date_gmt":"2014-04-29T06:54:01","guid":{"rendered":"http:\/\/www.strongd.net\/?p=1262"},"modified":"2014-04-29T14:54:01","modified_gmt":"2014-04-29T06:54:01","slug":"use-ssh-to-run-shell-script-on-a-remote-machine","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=1262","title":{"rendered":"use ssh to run shell script on a remote machine"},"content":{"rendered":"<p>Also, don&#8217;t forget to escape variables if you want to pick them up from the destination host.<\/p>\n<p>This has caught me out in the past.<\/p>\n<p>For example:<\/p>\n<p>user@host&gt; ssh user2@host2 &#8220;echo \\$HOME&#8221;<br \/>\nprints out \/home\/user2<\/p>\n<p>while<\/p>\n<p>user@host&gt; ssh user2@host2 &#8220;echo $HOME&#8221;<br \/>\nprints out \/home\/user<\/p>\n<p>Another example:<\/p>\n<p>user@host&gt; ssh user2@host2 &#8220;echo hello world | awk &#8216;{print \\$1}'&#8221;<br \/>\nprints out &#8220;hello&#8221; correctly.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Also, don&#8217;t forget to escape variables if you want to pick them up from the destination host. This has caught me out in the past. For example: user@host&gt; ssh user2@host2 &#8220;echo \\$HOME&#8221; prints out \/home\/user2 while user@host&gt; ssh user2@host2 &#8220;echo $HOME&#8221; prints out \/home\/user Another example: user@host&gt; ssh user2@host2 &#8220;echo hello world | awk &#8216;{print &hellip; <a href=\"https:\/\/www.strongd.net\/?p=1262\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">use ssh to run shell script on a remote machine<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-1262","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1262","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1262"}],"version-history":[{"count":1,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1262\/revisions"}],"predecessor-version":[{"id":1263,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1262\/revisions\/1263"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}