2

I should change to specific folder so that the output of the script can be exported into a file in that folder (123.txt in the example code below).

but this command, which I run from inside my ruby code

./iw2_broadcast.py

takes 5 minutes or more to complete. I try to append & to make it run in the background, but it seems it does not work.

Any ideas? Thanks

  Dir.chdir(@iw2_dir)
  ` ./iw2_broadcast.py -f 123.txt & `
  puts "123"

2 Answers 2

3

Create a shell script with the execution command

# py.sh
./iw2_broadcast.py

Execute the above shell script from ruby using system command

# ruby_script.rb
system("./py.sh")

Now your ruby code will be executed without waiting for the output

Sign up to request clarification or add additional context in comments.

Comments

1

Adding & works with system(). You can easily test it with:

system("sleep 1 &")

So for this precise example:

system("./iw2_broadcast.py -f 123.txt &")

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.