-----Original Message----- From: Benjamin Franz Sent: Wednesday, March 16, 2011 17:30 To: CentOS mailing list Subject: Re: [CentOS] perl one-liner issue
On 03/16/2011 01:42 PM, Joseph L. Casale wrote:
$conf['nagios_base'] =
I'd just search for that part, above.
Me to, and I never even got to the replacement as the
search for that
was bailing:)
The problem is trying to pass valid Perl though the bash shell . There is an insane amount of interaction between all the escapings involved in this specific pattern. The hard problem is getting bash to *not* change what you are passing to Perl before Perl sees it.
Use 'echo' as a stand-in for Perl and you will see what is actually being passed to Perl for execution (it most likely isn't what you think it is). Once you know you are feeding Perl the right thing, you can worry about getting the pattern for the substitution correct.
After enough poking and prodding you'll get something like this (after giving up on getting bash to not molest the ' characters before passing them to Perl):
'this string isn'"'"'t escaped \n\n :) '
I got used to this a long time ago...
's/($conf[\047nagios_base\047]\s*=\s*")/nagios/cgi-bin";/$
1stuffhere";/'
Is there some reason you can't use a straight Perl script instead of using bash to run a perl one liner?
-- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - - - Jason Pyeron PD Inc. http://www.pdinc.us - - Principal Consultant 10 West 24th Street #100 - - +1 (443) 269-1555 x333 Baltimore, Maryland 21218 - - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- This message is copyright PD Inc, subject to license 20080407P00.