SPUG: Quoting Question
Tim Maher
tim at consultix-inc.com
Mon Oct 16 21:05:53 PDT 2006
On Mon, Oct 16, 2006 at 05:04:47PM -0700, Asa Martin wrote:
> The echo line should be:
>
> $ssh->send("echo \"$line\" >> $new_file");
>
> That's the line that isn't working right.
Letting the shell see double-quotes around $line is
just asking for trouble, if you want it to remain unmolested.
The customary approach would be:
system "echo '$line'";
or, in your case:
$ssh->send("echo '$line' >> '$new_file'");
To understand the issues involved, check out
http://TeachMeUnix.com/quoting.html
-Tim
P.S. I'm teaching a class on Shell Programming from 12/11-13 in
Seattle.
*-------------------------------------------------------------------*
| Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX |
| tim at ( Consultix-Inc, TeachMePerl, or TeachMeUnix ) dot Com |
*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*
| UPCOMING CLASSES; 11/6: Minimal Perl 11/8-10: Intermediate Perl |
| * Check out my new book: "Minimal Perl for UNIX/Linux People" * |
| See MinimalPerl.com for details, free chapters, and ordering |
*-------------------------------------------------------------------*
More information about the spug-list
mailing list