On Mon, Mar 14, 2011 at 8:12 AM, duff <etienne.dufr...@googlemail.com>wrote:
> Hello, I am trying to export the latest tag of an svn repository to a > puppet client. > To do so, I would like to run the following command to get the latest > tag > /usr/bin/svn ls http://url_to_my_svn_repository/tags | /usr/bin/ > tail -1 > > However, I couldn't find a way to store the result of an exec in a > variable. > > Since the url to the repository will change depending on the project, > I decided to use a custom function and get it to run and return the > result of the command. > > module Puppet::Parser::Functions > newfunction(:get_latest_tag, :type => :rvalue) do |args| > cmd = "/usr/bin/svn ls http://" + arg[0] + " | /usr/bin/ > tail -1" > puts cmd > puts %x[ #{cmd} ] > puts 'the end' > end > end > > If you are actually using "puts" in your function as indicated, then your return value should be "nil". Have you tried your function this way: module Puppet::Parser::Functions newfunction(:get_latest_tag, :type => :rvalue) do |args| %x["/usr/bin/svn ls http://" + arg[0] + " | /usr/bin/tail -1"] end end This is straight Ruby code, so the result of the function is the return value of the last statement/expression evaluated. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.