By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,750 Members | 1,231 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,750 IT Pros & Developers. It's quick & easy.

RE: python/ruby question..

P: n/a
hey guys...

i managed to solve what i was attempting.. my goal was rather simple, to be
able to have a python script, call a ruby app, and be able to return a
value from the ruby (child) app to the parent.. blocking/unblocking wasn't
on my radar for now.

ultimately, my goal is to have an app on a master server, with that app
calling the ruby app using the remote functions (rsh/rexec for now).

so, on the master python, i have:

#test python script
import re
import os
import sys, string
import os.path
import subprocess

#print "foo"

a = subprocess.Popen(["/test1/test.rb",pp], stdout=subprocess.PIPE)
print "qq[8] = ",qq[8]
print "qq[9] = ",qq[9]
print "qq[10] = ",qq[10]

and on the child/ruby app:
#! /usr/local/bin/ruby

require 'rubygems'
require '/usr/local/lib/ruby/gems/1.8/gems/firewatir-1.1.1/firewatir'
include FireWatir

table = ff.table(:id, "dataTable").to_a
#puts table
#puts "blah...."
aa = table[1][1]
puts table[1][1]

#ff.text_field(:name, "q").set("ruby")
#ff.button(:value,"Google Search").click
#puts ff.element_by_xpath("//a[@class='l']").text
#puts "hi there"
#return (33)
this pretty much works as it needs to for now...

like i said.. rather simple, as it should be.

so thanks for the help/suggestions from everyone!

-----Original Message-----
From: py*****************************************@python .org
[mailto:py*****************************************]On Behalf
Of Paul McGuire
Sent: Thursday, June 19, 2008 6:27 PM
To: py*********
Subject: Re: python/ruby question..
On Jun 18, 10:33*pm, "bruce" <bedoug...@earthlink.netwrote:

can someone point me to where/how i would go about calling a ruby app from
python app, and having the python app being able to get a returned value
from the ruby script.
I'm betting that Ruby is similar to Python in that a Ruby interpreter
can be embedded within other applications. Why not implement
something like ruby_exec(), similar to Python's exec, which takes a
string containing Ruby code, and a dict of variables that can be
accessed and updated from the executed Ruby? Then no messing around
with subprocess, XMLRPC, firing up processes, etc. - just create the
string and call it.

(Implementation left as an exercise for the reader.)

-- Paul

Jun 27 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.