Linux – Puppet read output of command and store in a variable

linuxpuppet

I am very new to puppet and trying to execute my puppet script but its failing all the time.

I want to store the output of below bash command and want to store in a variable which I can use later:

/usr/bin/head -1 /tmp/testfile.out | cut -d',' -f2'3

Which I am passing to my puppet script to read a file from another location

variable => generate('/usr/bin/head -1 /tmp/testfile.out | cut -d',' -f2'),
command => "/bin/cp /${variable}/application/myscript.sh /var/tmp/myscript.sh",
creates => "/var/tmp/myscript.sh",

But when I execute this puppet script it fails. I am not sure even if above one is correct too. Any help would be appreciated.

Thanks

EDITED

testfile.out contains a cron data which is generated using my custom php script in that I have application name on the first line of the file. Sample entry of the file :

cat testfile.out
server.amazon.com,zimbra,1080,3000

I have a script which sits on a nfs share which starts with the application name $variable and I need to copy on that server which will run check for all zimbra related files and folders. Even I am not sure about this script what it does exactly as its a binary file..

Best Answer

Use this

command => "/bin/cp \"`/usr/bin/head -1 /tmp/testfile.out | cut -d\",\" -f2`\"/application/myscript.sh /var/tmp/myscript.sh",
creates => "/var/tmp/myscript.sh"

It works for me ..