<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>