<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Using SSH to Send Variables in Scripts</title>
	<atom:link href="http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts.html/feed" rel="self" type="application/rss+xml" />
	<link>http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts.html</link>
	<description>Big, Honkin' Systems Stuff</description>
	<lastBuildDate>Mon, 09 Jan 2012 19:19:37 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: systemsboy</title>
		<link>http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts.html/comment-page-1#comment-1822</link>
		<dc:creator>systemsboy</dc:creator>
		<pubDate>Mon, 15 Nov 2010 13:16:12 +0000</pubDate>
		<guid isPermaLink="false">http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts/#comment-1822</guid>
		<description>Wow. That&#039;s great. Thanks!

-systemsboy</description>
		<content:encoded><![CDATA[<p>Wow. That&#8217;s great. Thanks!</p>
<p>-systemsboy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joey</title>
		<link>http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts.html/comment-page-1#comment-1820</link>
		<dc:creator>Joey</dc:creator>
		<pubDate>Sat, 13 Nov 2010 23:25:34 +0000</pubDate>
		<guid isPermaLink="false">http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts/#comment-1820</guid>
		<description>#!/bin/bash

echo &quot;Enter User Name and press return...&quot;
read username

ssh -t user@localhost &quot;ls ~$username&quot;





This will work just fine! You need to use double quotes to tell bash to interpolate variables. Your code actually helped me figure this out, since you use single quotes in the first [non-working] example and double quotes in the second [working] example.</description>
		<content:encoded><![CDATA[<p>#!/bin/bash</p>
<p>echo &#8220;Enter User Name and press return&#8230;&#8221;<br />
read username</p>
<p>ssh -t user@localhost &#8220;ls ~$username&#8221;</p>
<p>This will work just fine! You need to use double quotes to tell bash to interpolate variables. Your code actually helped me figure this out, since you use single quotes in the first [non-working] example and double quotes in the second [working] example.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: systemsboy</title>
		<link>http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts.html/comment-page-1#comment-589</link>
		<dc:creator>systemsboy</dc:creator>
		<pubDate>Tue, 01 Jul 2008 23:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts/#comment-589</guid>
		<description>pradeep,&lt;br/&gt;&lt;br/&gt;You can either log in to each machine 1-at-a-time, or you can use a for or while loop to automate the process, as per the comments in this article:&lt;br/&gt;http://systemsboy.blogspot.com/2006/07/send-remote-commands-via-ssh.html&lt;br/&gt;&lt;br/&gt;-systemsboy</description>
		<content:encoded><![CDATA[<p>pradeep,</p>
<p>You can either log in to each machine 1-at-a-time, or you can use a for or while loop to automate the process, as per the comments in this article:<br /><a href="http://systemsboy.blogspot.com/2006/07/send-remote-commands-via-ssh.html" rel="nofollow">http://systemsboy.blogspot.com/2006/07/send-remote-commands-via-ssh.html</a></p>
<p>-systemsboy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts.html/comment-page-1#comment-588</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Thu, 26 Jun 2008 13:41:00 +0000</pubDate>
		<guid isPermaLink="false">http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts/#comment-588</guid>
		<description>THANKS THANKS THANKS!!!!&lt;br/&gt;&lt;br/&gt;From Chile</description>
		<content:encoded><![CDATA[<p>THANKS THANKS THANKS!!!!</p>
<p>From Chile</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pradeep</title>
		<link>http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts.html/comment-page-1#comment-587</link>
		<dc:creator>Pradeep</dc:creator>
		<pubDate>Wed, 25 Jun 2008 20:13:00 +0000</pubDate>
		<guid isPermaLink="false">http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts/#comment-587</guid>
		<description>how does this work if you need to login to multiple servers and run the command at the same time?</description>
		<content:encoded><![CDATA[<p>how does this work if you need to login to multiple servers and run the command at the same time?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: systemsboy</title>
		<link>http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts.html/comment-page-1#comment-586</link>
		<dc:creator>systemsboy</dc:creator>
		<pubDate>Thu, 20 Sep 2007 00:05:00 +0000</pubDate>
		<guid isPermaLink="false">http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts/#comment-586</guid>
		<description>Awesome! I haven&#039;t tried this, but this sounds like exactly what I was looking for a way to do and not finding. Hence my roundabout method. If this works for me I&#039;ll update my post.&lt;br/&gt;&lt;br/&gt;Thanks!&lt;br/&gt;&lt;br/&gt;-systemsboy</description>
		<content:encoded><![CDATA[<p>Awesome! I haven&#8217;t tried this, but this sounds like exactly what I was looking for a way to do and not finding. Hence my roundabout method. If this works for me I&#8217;ll update my post.</p>
<p>Thanks!</p>
<p>-systemsboy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Den Zuko</title>
		<link>http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts.html/comment-page-1#comment-585</link>
		<dc:creator>Den Zuko</dc:creator>
		<pubDate>Wed, 19 Sep 2007 22:31:00 +0000</pubDate>
		<guid isPermaLink="false">http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts/#comment-585</guid>
		<description>right so you went the round about way of doing this. the problem was with variable expansion.&lt;br/&gt;&lt;br/&gt;Here&#039;s a simple two liner for yah:&lt;br/&gt;echo -n &quot;Username: &quot; &amp;&amp; read username&lt;br/&gt;ssh -t root@remote.site &quot;ls ~${username}&quot;&lt;br/&gt;&lt;br/&gt;what happens here is when you put a variable name within ${} instead of just a $var_name the shell expands it, like hitting tab on the cli or echoing the values. This is not only useful in this case but also if you have ANSI colors, or values returned from a command.</description>
		<content:encoded><![CDATA[<p>right so you went the round about way of doing this. the problem was with variable expansion.</p>
<p>Here&#8217;s a simple two liner for yah:<br />echo -n &#8220;Username: &#8221; &#038;&#038; read username<br />ssh -t <a href="mailto:root@remote.site">root@remote.site</a> &#8220;ls ~${username}&#8221;</p>
<p>what happens here is when you put a variable name within ${} instead of just a $var_name the shell expands it, like hitting tab on the cli or echoing the values. This is not only useful in this case but also if you have ANSI colors, or values returned from a command.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fabio Leitao</title>
		<link>http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts.html/comment-page-1#comment-584</link>
		<dc:creator>Fabio Leitao</dc:creator>
		<pubDate>Tue, 21 Aug 2007 21:33:00 +0000</pubDate>
		<guid isPermaLink="false">http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts/#comment-584</guid>
		<description>Me and a friend had the same problem, and after a while strugling with the script and debuging.&lt;br/&gt;&lt;br/&gt;It seemes the ssh messes with the stdin and halted our while statement.&lt;br/&gt;&lt;br/&gt;Try setting -n on the ssh options. It worked for us.</description>
		<content:encoded><![CDATA[<p>Me and a friend had the same problem, and after a while strugling with the script and debuging.</p>
<p>It seemes the ssh messes with the stdin and halted our while statement.</p>
<p>Try setting -n on the ssh options. It worked for us.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ithcy</title>
		<link>http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts.html/comment-page-1#comment-583</link>
		<dc:creator>Ithcy</dc:creator>
		<pubDate>Tue, 21 Aug 2007 20:48:00 +0000</pubDate>
		<guid isPermaLink="false">http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts/#comment-583</guid>
		<description>Hello SB,&lt;br/&gt;&lt;br/&gt;I am having some serious dificulties regarding a ssh runing remote script a sent by a local script in the midle of a loop:&lt;br/&gt;&lt;br/&gt;#!/bin/bash&lt;br/&gt;while [statement]; do&lt;br/&gt;yada; yada; yada;&lt;br/&gt;if [statement]; then&lt;br/&gt;ssh -p xxxx $USER@$HOST `remote_script.sh`&lt;br/&gt;fi&lt;br/&gt;yada; yada; yada;&lt;br/&gt;done&lt;br/&gt;&lt;br/&gt;The thing is, even if the while has many things else to do, the first time it runs the remote script (or command) via ssh, the while exits with no particular reazon.&lt;br/&gt;&lt;br/&gt;It does not matter if the remote commands ends up successfully or not.&lt;br/&gt;&lt;br/&gt;Is there any mandatory &quot;DROP ALL LOOPS&quot; after any SSH sort of undocumented &quot;feature&quot;?&lt;br/&gt;&lt;br/&gt;The real bizzar portion is, that if I force the remote script to run on the backgrounf with a &amp; like this:&lt;br/&gt;&lt;br/&gt;#!/bin/bash&lt;br/&gt;while [statement]; do&lt;br/&gt;yada; yada; yada;&lt;br/&gt;if [statement]; then&lt;br/&gt;ssh -p xxxx $USER@$HOST `remote_script.sh &amp;`&lt;br/&gt;fi&lt;br/&gt;yada; yada; yada;&lt;br/&gt;done&lt;br/&gt;&lt;br/&gt;...it goes on, but the remote_script.sh is supposed to run serialized and never in paralel with another instance of it self, therefore crasing.&lt;br/&gt;&lt;br/&gt;Thanx in advance.</description>
		<content:encoded><![CDATA[<p>Hello SB,</p>
<p>I am having some serious dificulties regarding a ssh runing remote script a sent by a local script in the midle of a loop:</p>
<p>#!/bin/bash<br />while [statement]; do<br />yada; yada; yada;<br />if [statement]; then<br />ssh -p xxxx $USER@$HOST `remote_script.sh`<br />fi<br />yada; yada; yada;<br />done</p>
<p>The thing is, even if the while has many things else to do, the first time it runs the remote script (or command) via ssh, the while exits with no particular reazon.</p>
<p>It does not matter if the remote commands ends up successfully or not.</p>
<p>Is there any mandatory &#8220;DROP ALL LOOPS&#8221; after any SSH sort of undocumented &#8220;feature&#8221;?</p>
<p>The real bizzar portion is, that if I force the remote script to run on the backgrounf with a &#038; like this:</p>
<p>#!/bin/bash<br />while [statement]; do<br />yada; yada; yada;<br />if [statement]; then<br />ssh -p xxxx $USER@$HOST `remote_script.sh &#038;`<br />fi<br />yada; yada; yada;<br />done</p>
<p>&#8230;it goes on, but the remote_script.sh is supposed to run serialized and never in paralel with another instance of it self, therefore crasing.</p>
<p>Thanx in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: systemsboy</title>
		<link>http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts.html/comment-page-1#comment-582</link>
		<dc:creator>systemsboy</dc:creator>
		<pubDate>Thu, 05 Jul 2007 15:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://systemsboy.com/2006/11/using-ssh-to-send-variables-in-scripts/#comment-582</guid>
		<description>Should be. Why don&#039;t you give it a try?&lt;br/&gt;&lt;br/&gt;ssh -t user@host &#039;passwd username&#039;&lt;br/&gt;&lt;br/&gt;-systemsboy</description>
		<content:encoded><![CDATA[<p>Should be. Why don&#8217;t you give it a try?</p>
<p>ssh -t user@host &#8216;passwd username&#8217;</p>
<p>-systemsboy</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 1/13 queries in 0.010 seconds using disk: basic
Object Caching 365/366 objects using disk: basic

Served from: systemsboy.com @ 2012-02-10 03:15:22 -->
