D
D
delaf2011-10-11 08:45:28
ruby
delaf, 2011-10-11 08:45:28

How to run a ruby ​​file with another ruby ​​file? (linux)

Hello

I'm running an rb file using cron to check the state of the flag.

The flag is a text file where the first line is 0 or 1
If the value of the flag is 1 then you need to run another rb file to work. (in a separate terminal window, I guess)

How to do this?

I understand that it is possible to write on bash, but it would be desirable means of ruby

​​PS. I found this command, but it doesn't work

do shell script "ruby pro.rb"

Answer the question

In order to leave comments, you need to log in

6 answer(s)
I
int03e, 2011-10-11
@int03e

system("/path/to/other/file.rb")

E
edelweard, 2011-10-11
@edelweard

Check that the path to Ruby is also absolute. For example, it's better to write like this:
system("/opt/local/bin/ruby /path/to/other/file.rb")
or add a shebang to the beginning of the second ruby ​​file and make it executable:
#!/opt/ local/bin/ruby
And then you can system("path/to/other/file.rb")

A
antivir, 2011-10-11
@antivir

5 ways to run commands from Ruby

D
delaf, 2011-10-11
@delaf

thanks… I seem to be doing this, but…
if I run the 1.rb file manually, then it launches the 2.rb file,
but if I run it through cron, then it runs, but where the system/exec lines are, it doesn’t work,
and accordingly but does not run 2.rb.
And in the processes 1.rb you can see that it has started.
What will be your thoughts on this? Why is this happening?

S
Stanislav Agarkov, 2011-10-11
@stas_agarkov

See /var/log/syslog for crontab logs.

E
edelweard, 2011-10-11
@edelweard

Why would you want to run a ruby ​​file as an executable anyway? Why not just include it in the main (require) and call the right method when you need it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question