<div>The echo line should be:</div>
<div>&nbsp;</div>
<div>$ssh-&gt;send(&quot;echo \&quot;$line\&quot; &gt;&gt; $new_file&quot;);</div>
<div>&nbsp;</div>
<div>That's the line that isn't working right.</div>
<div>&nbsp;</div>
<div>Thanks!<br><br>&nbsp;</div>
<div><span class="gmail_quote">On 10/16/06, <b class="gmail_sendername">Asa Martin</b> &lt;<a href="mailto:asa.martin@gmail.com">asa.martin@gmail.com</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>Hi everyone,</div>
<div>&nbsp;</div>
<div>Long-time lurker, infrequent poster, but I have this really annoying quoting question. I'm writing a remote SSH script (but not using Net::SSH so any solution can't utilize any special Net::SSH stuff). I log into a remote system using ssh, read a file from the remote system into memory, parse through it line by line, and on certain lines make substitutions. Then I need to write the new file to the system. I am trying to send the changed stuff to the new file using the echo command, but it's not working very well. 
</div>
<div>&nbsp;</div>
<div>For example:</div>
<div>&nbsp;</div>
<div>for my $line (@array_of_lines)</div>
<div>&nbsp;&nbsp;&nbsp; if ($line =~ /com2sec\s+.*$stuff_to_match/) {</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $line =~ s/$stuff_to_match/$new_stuff/;</div>
<div>&nbsp;&nbsp;&nbsp; }</div>
<div>&nbsp;&nbsp;&nbsp; $ssh-&gt;send('echo &quot;$line&quot;'); # this expands stuff I don't want it to!</div>
<div>}</div>
<div>&nbsp;</div>
<div>$stuff_to_match and $new_stuff contain special characters, like quotes, $, @, etc. that I don't want expanded in the regular expression. And $line contains tabs, quotations, special characters, including # signs and $ signs, etc. I'll want the white space and quotes to come across correctly, but any variable names that might be in $line I don't want expanded. 
</div>
<div>&nbsp;</div>
<div>Any help would be appreciated.</div>
<div>&nbsp;</div>
<div>Thanks,</div>
<div>&nbsp;</div>
<div>Asa</div>
<div>&nbsp;</div>
<div>P.S. The remote system is a Linux-type box (F5 Load Balancer) so I have the full set of Linux tools available if something better than echo would work. The problem is that I have only that one send() routine of some unknown SSH module. 
</div><br>_____________________________________________________________<br>Seattle Perl Users Group Mailing List<br>&nbsp; &nbsp; POST TO: <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:spug-list@pm.org">spug-list@pm.org
</a><br>SUBSCRIPTION: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://mail.pm.org/mailman/listinfo/spug-list" target="_blank">http://mail.pm.org/mailman/listinfo/spug-list</a><br>&nbsp; &nbsp;MEETINGS: 3rd Tuesdays
<br>&nbsp; &nbsp;WEB PAGE: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://seattleperl.org/" target="_blank">http://seattleperl.org/</a><br><br></blockquote></div><br>