Sifungurux
Sifungurux

Reputation: 1

Passing an argument from ruby to a python scripts

I have a problem that I hope you guys can help me out with. Im making a home automation system with RPi + Piface to control devices on the network.

#----------------------------------------------------------------------------------------
#                           LIGHTS Automation
#----------------------------------------------------------------------------------------
  room=0

  listen_for /Turn on kitchen lights/i do
    lights('kitchen')
    request_completed
  end

  def lights(varible)
     IO.popen("python /root/SiriProxy/plugins/siriproxy-teamsiri/TeamsiriPython/test.py varible")
  end

this is my line of code. Im calling a python script and it works fine but I want use functions "varible"will be the varible to pass to the script but it does not send it as a varible but a string. Any one got some good ideas how to solve it

Upvotes: 0

Views: 269

Answers (1)

mcfinnigan
mcfinnigan

Reputation: 11638

Change

IO.popen("python /root/SiriProxy/plugins/siriproxy-teamsiri/TeamsiriPython/test.py varible")

to

IO.popen("python /root/SiriProxy/plugins/siriproxy-teamsiri/TeamsiriPython/test.py #{variable}")

and the variable value will be substituted into the string.

Note that this only works inside double-quoted strings.

Upvotes: 2

Related Questions