Problem solved... By using a separate file instead of putting the 
provisioning inline everything works great.

On Monday, January 26, 2015 at 8:49:17 AM UTC-6, Sterling Anderson wrote:
>
> I should have removed the line with ls in my example, that was just to 
> prove to myself that the file was really there. However, even with your 
> example I get the same error.
>
> ==> default: /tmp/vagrant-shell: line 2: unexpected EOF while looking for 
> matching `''
> ==> default: /tmp/vagrant-shell: line 3: syntax error: unexpected end of 
> file
>
> I'm on OS X, I don't know if that would make a difference.
>
>
> On Sunday, January 25, 2015 at 2:57:13 PM UTC-6, Alvaro Miranda Aguilera 
> wrote:
>>
>> Hello
>>
>> if I read the code, what I understand is you want to re use the $2
>>
>> then those 2 lines, should be 1 , joined by |
>>
>> command1 | command2
>>
>> you have 
>>
>> command1
>> command2
>>
>> not sure why work manually but as is it shouldn't.
>>
>> The error is because the quotes ' are too many..
>>
>> try with "" around -F
>>
>> now, AWK $2 is not the user, ls -l, give you the user in $3
>>
>>
>> If what you want, is say.. replace DB_USER with the name of the user that 
>> own that php file.. sorry if I got it wrong.. then this works:
>>
>> z2-3:oracle7 kikitux$ cat html/wp-config.php                             
>>                                                                             
>>                                                                             
>>             
>> 'DB_USER'                                                                 
>>                                                                             
>>                                                                             
>>             
>> z2-3:oracle7 kikitux$ vagrant provision                                   
>>                                                                             
>>                                                                             
>>             
>> ==> default: Running provisioner: shell...                               
>>                                                                             
>>                                                                             
>>              
>>     default: Running: inline script                                       
>>                                                                             
>>                                                                             
>>             
>> ==> default: vagrant                                                     
>>                                                                             
>>                                                                             
>>              
>> z2-3:oracle7 kikitux$ cat html/wp-config.php                             
>>                                                                             
>>                                                                             
>>             
>> 'vagrant'                  
>>
>>
>> Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
>>   config.vm.box = "kikitux/oracle7"
>>   config.vm.synced_folder ".", "/var/www"
>>   config.vm.provision "shell", inline: <<-SHELL
>>     USER="`ls -l /var/www/html/wp-config.php |awk '{print $3}'`"
>>     echo $USER
>>     sed -e "s/DB_USER/$USER/g" -i /var/www/html/wp-config.php
>>   SHELL
>> end
>>
>>
>>
>> On Mon, Jan 26, 2015 at 4:11 AM, Sterling Anderson <
>> [email protected]> wrote:
>>
>>> I'm trying to grab the DB_USER and DB_PASSWORD fields from a 
>>> wp-config.php file during provisioning. I cannot get this information out 
>>> during provisioning. Below is the Vagrantfile stripped down to almost 
>>> nothing using awk. The following sed command has also been tried as a 
>>> replacement for the awk command.
>>>
>>> sed -n "/^ *define( *'DB_USER', *'\([^']*\)'.*/ {s//\1/p;q;}" /var/www/
>>> html/wp-config.php
>>>
>>>
>>> Vagrant.configure(2) do |config|
>>>   config.vm.box = "ubuntu/trusty64"
>>>   config.vm.synced_folder ".", "/var/www"
>>>   
>>>   config.vm.provision "shell", inline: <<-SHELL
>>>     ls -l /var/www/html/wp-config.php
>>>     awk -F '\'' '/DB_USER/ {print $2}' /var/www/html/wp-config.php
>>>   SHELL
>>>
>>> end
>>>
>>> Both commands work when run from the VM after it is up. However, I get 
>>> errors like the following when trying to run them during provisioning.
>>>
>>> ==> default: /tmp/vagrant-shell: line 2: unexpected EOF while looking 
>>> for matching `'' 
>>> ==> default: /tmp/vagrant-shell: line 3: syntax error: unexpected end of 
>>> file 
>>> The SSH command responded with a non-zero exit status. Vagrant 
>>> assumes that this means the command failed. The output for this command 
>>> should be in the log above. Please read the output to determine what 
>>> went wrong.
>>>
>>>
>>> The file is located at the path specified in the synced folder.
>>>
>>> Any ideas on what I need to do to get this working?
>>>
>>> -- 
>>> 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].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to