Answer the question
In order to leave comments, you need to log in
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
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")
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?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question