Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: creating Shell Script using Perl

by AnomalousMonk (Archbishop)
on Sep 06, 2017 at 05:48 UTC ( [id://1198737]=note: print w/replies, xml ) Need Help??


in reply to Re^2: creating Shell Script using Perl
in thread creating Shell Script using Perl

print FILE "    [[ -f \"$FILE\" ]] && grep -q \"$STRING\" \"$FILE\" && echo \"DB Installation is completed\" && break\n";

$FILE and $STRING appear in a Perl double-quoted string. Perl will try to interpolate these Perl variables into the string, but you really intend them for the shell. In order to protect them from Perl interpolation, escape them with a  \ (backslash) (as afoken has written). So the statement would look something like (untested)
    print FILE "    [[ -f \"\$FILE\" ]] && grep -q \"\$STRING\" \"\$FILE\" && echo \"DB Installation is completed\" && break\n";
or maybe, since you don't really seem to need Perl interpolation at all in this statement,
    print FILE '    [[ -f "$FILE" ]] && grep -q "$STRING" "$FILE" && echo "DB Installation is completed" && break', "\n";
(or use a here-doc as kcott suggested).


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1198737]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2024-03-28 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found