Iam trying to pass num value from one resource to another resource but not able to do so

num = 1433

ruby_block “check_port” do
block do

loop do

system(“powershell.exe TNC -ComputerName ‘ix1csqlwin1.am.lilly.com’ -Port #{num} -InformationLevel Quiet 3>&1 > C:\Ansh\result.txt”)

data = File.read(“C:\Ansh\result.txt”)

if data.chomp == “False” then
break
end
num -= 1
node.run_state[‘port_value’] = num
end
end
end

trying to pass node.run_state[‘port_value’] to another resource but every time iam getting nil value in name: ‘TcpPort’

registry_key “#{reg_prefix}\SuperSocketNetLib\Tcp\IPAll” do
values [{ name: ‘Enabled’, type: :dword, data: node[‘sql_installfirst’][‘tcp_enabled’] ? 1 : 0 },
{ name: ‘TcpPort’, type: :string, data: node.run_state[‘port_value’] },
{ name: ‘TcpDynamicPorts’, type: :string, data: node[‘sql_installfirst’][‘tcp_dynamic_ports’].to_s }]
recursive true
notifies :restart, “service[#{service_name}]”, :immediately

end