- From: Noah Kantrowitz <
>
- To:
- Subject: [chef] Re: Chef messing up sed commmand
- Date: Mon, 22 Apr 2013 01:04:20 -0700
On Apr 22, 2013, at 12:48 AM,
<
>
wrote:
>
Hi
>
>
I am trying to get a bash script to work that has a sed command in it.
>
The sed
>
command has escape characters in it. For some reason Chef seems to be
>
taking
>
these escape characters out and trying to execute the sed script which
>
fails.
>
The sed script works in the console
>
>
Below is the original test script I made. This works as expected.
>
>
if [ $(grep -c postrotate $1) -ne 0 ]; then
>
if [ $(grep -c checksum_log.sh $1) -ne 1 ]; then
>
sed -i 's/endscript/\/usr\/bin\/checksum_log.sh $1\n endscript/' $1
>
fi
>
fi
>
>
The Bash script block in Chef is the same as above contained within a <<-EOF
>
block with $1 being replaced with a file name.
Make that <<-'EOF' to make it a non-interpolated string block, otherwise you
have to deal with Ruby string formatting on top of Bash formatting. You can
also use %q[...]
--Noah
Attachment:
signature.asc
Description: Message signed with OpenPGP using GPGMail
Archive powered by MHonArc 2.6.16.