def action_run
case @new_resource.name_type
when "sname"
node = "-sname #{@new_resource.node_name}"
when "name"
node = "-name #{@new_resource.node_name}"
end
if @new_resource.cookie
cookie = "-c #{@new_resource.cookie}"
else
cookie = ""
end
if @new_resource.distributed
distributed = "-s"
else
distributed = ""
end
command = "erl_call -e #{distributed} #{node} #{cookie}"
status = popen4(command, :waitlast => true) do |pid, stdin, stdout, stderr|
Chef::Log.debug("Running erl_call[#{@new_resource.name}]")
Chef::Log.debug("erl_call[#{@new_resource.name}] command: #{command}")
Chef::Log.debug("erl_call[#{@new_resource.name}] code: #{@new_resource.code}")
@new_resource.code.each_line { |line| stdin.puts "#{line.chomp!}" }
stdin.close
Chef::Log.info("Ran erl_call[#{@new_resource.name}] successfully")
Chef::Log.debug("erl_call[#{@new_resource.name}] output: ")
stdout.each_line { |line| Chef::Log.debug("#{line}")}
end
end