Hi Colin, The issue is not quotes, but rather the \n and \t characters. I assume you want those to be the literally newline and tab characters, but they are getting expanded **in the string**. You need to escape the backslash:
"%s\\\t %s\\\n"
The easiest way to debug this type of issue is to add the following line after
$provision_script:
puts $provision_script
If the result (on the terminal) does not look exactly as you expect, Ruby is
probably reading variables/functions that you actually want Bash reading. If
you do not need interpolation, you can also use %q instead of <<- and Ruby will
just accept the string as-is.
Best,
Seth
> On Oct 29, 2014, at 2:31 AM, Colin Kincaid Williams <[email protected]> wrote:
>
> Hi I'm trying the following:
>
> $provision_script= <<SCRIPT
> /bin/bash -c "%s\t %s\n" "$(hostname)" "$(ip -f inet -o addr show
> eth1 | awk "-F[ /]+" "{ print \$4 }")" >> /vagrant/hosts
> SCRIPT
>
> config.vm.provision :shell, :inline => $provision_script
>
>
> I expected everything between the SCRIPT lines to function like a bash shell
> script. However it seems like ruby is interpreting the quotes differently
> than what I get from the shell. Then what is a SCRIPT ? I assume that to get
> the behavior I would like, I need to create a shell script on the vagrant
> host and use the other provisioning methods.
>
> I guess I wanted to state that I like the Vagrant docs, but many things seem
> short on details. I'm not even sure of some fundamental things like how boxes
> work from reading the docs. Will there be any effort to make the
> documentation more complete? I wish there was a more wiki-ish interface, or a
> place to leave comments under the documentation, like many old projects used
> to use. Where do I go for more complete information, without sacrificing time
> ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
smime.p7s
Description: S/MIME cryptographic signature
