Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78316 > unrolled thread

cannot run a ruby script from a python script.

Started byShawn Bright <shawn@skrite.net>
First post2014-09-24 16:57 -0700
Last post2014-09-25 06:14 -0700
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  cannot run a ruby script from a python script. Shawn Bright <shawn@skrite.net> - 2014-09-24 16:57 -0700
    Re: cannot run a ruby script from a python script. Cameron Simpson <cs@zip.com.au> - 2014-09-25 10:44 +1000
    Re: cannot run a ruby script from a python script. Shawn Bright <shawn@skrite.net> - 2014-09-25 06:14 -0700

#78316 — cannot run a ruby script from a python script.

FromShawn Bright <shawn@skrite.net>
Date2014-09-24 16:57 -0700
Subjectcannot run a ruby script from a python script.
Message-ID<8c24ba60-9f0c-4b29-8c3e-64139af3a676@googlegroups.com>
hello all. 

i have a linux computer that i use to run a GUI (wxGTK) program. In this program, there is a call to run an external ruby script.

command = "ruby run_my_command.rb &" 
os.system(command)

however, when it runs, i get this in the terminal
sh: 1: ruby: not found

i had considered that the path to the executable was messed up or somesuch, but when i just run python in the interpreter, it works fine.

also, i have another computer with identical hardware, same OS, same package versions that it does work on also. This machine is to be a backup. 

Another note: When i run which ruby i get the path to the ruby executable. If i use that in my code, it will run, however, it will not be able to find any of the modules that i need for the ruby script to import.

example

command = "/path/to/ruby run_my_command.rb &" 
os.system(command) 

will run the ruby script, but the ruby script will not be able to import any of it's modules.


thanks for any tips on this.

[toc] | [next] | [standalone]


#78319

FromCameron Simpson <cs@zip.com.au>
Date2014-09-25 10:44 +1000
Message-ID<mailman.14337.1411605884.18130.python-list@python.org>
In reply to#78316
On 24Sep2014 16:57, Shawn Bright <shawn@skrite.net> wrote:
>i have a linux computer that i use to run a GUI (wxGTK) program. In this 
program, there is a call to run an external ruby script.
>
>command = "ruby run_my_command.rb &"
>os.system(command)
>
>however, when it runs, i get this in the terminal
>sh: 1: ruby: not found
>
>i had considered that the path to the executable was messed up or somesuch, but when i just run python in the interpreter, it works fine.
>
>also, i have another computer with identical hardware, same OS, same package versions that it does work on also. This machine is to be a backup.
>
>Another note: When i run which ruby i get the path to the ruby executable. If i use that in my code, it will run, however, it will not be able to find any of the modules that i need for the ruby script to import.

For your edification: modify your command to be this:

   command = "which ruby; echo $PATH; ruby run_my_command.rb &"

and see if the output says what you expect.

 From the behaviour you describe I would expect that the GUI program, when it 
fails, is not being invoked from your command line but from some menu or 
suchlike. Further, I would guess that the invoking program (window manager, 
whatever) does not have ruby in its $PATH. This same effect obtains when you 
use the full path to ruby (usually a bad idea because your script may not work 
on another system where ruby is somewhere different) because like $PATH, the 
ruby search path also lacks the directories where the modules reside.

When you run it from your command prompt or from the python interpreter your 
environment is already set up with this extra information.

Cheers,
Cameron Simpson <cs@zip.com.au>

C makes it easy for you to shoot yourself in the foot.  C++ makes that
harder, but when you do, it blows away your whole leg.
- Bjarne Stroustrup

[toc] | [prev] | [next] | [standalone]


#78340

FromShawn Bright <shawn@skrite.net>
Date2014-09-25 06:14 -0700
Message-ID<a57f894f-6c9b-47c5-8bb5-2cc164875556@googlegroups.com>
In reply to#78316
On Wednesday, September 24, 2014 6:57:34 PM UTC-5, Shawn Bright wrote:
> hello all. 
> 
> 
> 
> i have a linux computer that i use to run a GUI (wxGTK) program. In this program, there is a call to run an external ruby script.
> 
> 
> 
> command = "ruby run_my_command.rb &" 
> 
> os.system(command)
> 
> 
> 
> however, when it runs, i get this in the terminal
> 
> sh: 1: ruby: not found
> 
> 
> 
> i had considered that the path to the executable was messed up or somesuch, but when i just run python in the interpreter, it works fine.
> 
> 
> 
> also, i have another computer with identical hardware, same OS, same package versions that it does work on also. This machine is to be a backup. 
> 
> 
> 
> Another note: When i run which ruby i get the path to the ruby executable. If i use that in my code, it will run, however, it will not be able to find any of the modules that i need for the ruby script to import.
> 
> 
> 
> example
> 
> 
> 
> command = "/path/to/ruby run_my_command.rb &" 
> 
> os.system(command) 
> 
> 
> 
> will run the ruby script, but the ruby script will not be able to import any of it's modules.
> 
> 
> 
> 
> 
> thanks for any tips on this.

I tried this with the same results. 
I am executing the GUI program from a terminal. It is a data engine that only really can serve our company so no reason to create menu entries for it and such. 
It did try to execute the ruby code, but could not.

Thanks for your help.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web